php - Merging multiple multidimensional arrays -



php - Merging multiple multidimensional arrays -

i have variable number of multidimensional arrays same 4 possible values each item.

for example:

array ( [companyid] => 1 [employeeid] => 1 [role] => "something" [name] => "something" )

but every array may have different ammount of items within it.

i want turn arrays 1 single table lots of rows. tried array_merge() end table 8, 12, 16... columns instead of more rows.

so... ideas?

thanks

didn't test it, seek following:

$table = array(); $columns = array('companyid' => '', 'employeeid' => '', 'role' => '', 'name' => ''); foreach($array $item) { $table[] = array_merge($columns, $item); }

this should work since documentation array_merge say:

if input arrays have same string keys, later value key overwrite previous one.

so either value of current item or default value can specify in $columns array.

php arrays

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -