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' ) )
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?
$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);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community