Support the ongoing development of Laravel.io →
Input Database Eloquent
Last updated 2 years ago.
0

You have this: $fo = array( 'lang' => array( 0 => 'en', 1 => 'fr ), 'titile' => array( 0 => 'good like', 1 => 'good like' ) )

You need this: $foo = array( 0 => array( 'lang' => 'en', 'title' => 'good like' ), 1 => array( 'lang' => 'fr', 'title' => 'good like2' ) )

Last updated 2 years ago.
0

Thanks to reply..

How do I do ?

<input type="text" name="lang[]" placeholder="lang..."> <input type="text" name="title[]" placeholder="title...">

can you help me?

Last updated 2 years ago.
0
$langArray = Input::get('lang');
$titleArray = Input::get('title');

if(count($langArray) > count($titleArray))
    $count = count($titleArray);
else $count = count($langArray);
//You know length of the shorter array

$items = array();
foreach($i = 0; $i < $count; $i++){
    $item = array('lang' => $langArray[$i], 'title' => $titleArray[$i]);
    //if you work with models
    //$item = new Model(array(...));
    //$item->save();
    $items[] = $item;
}

DB::table('table_name')->insert($items);
Last updated 2 years ago.
0

thenks good job

Last updated 2 years ago.
0

Please, make this solved.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

intrepidtr intrepidtr Joined 11 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.