php - Set some array value as key of an array -
i have tried line of code display array:
foreach($users_array $value){ echo "<pre>"; print_r($value); }
which display kind of array.
array ( [auto_id] => 45 [id] => 20151116 [name] => peter 2 [department] => [position] => [rate] => 300 [date_added] => 2017-07-26 09:31:44 ) array ( [auto_id] => 80 [id] => 20160410 [name] => john 2 [department] => [position] => [rate] => 400 [date_added] => 2017-07-26 09:31:48 )
now wanted make id of employee key of array , make them 1 multi-dimensional array.
example output should this:
array ( [20151116] => array ( [auto_id] => 45 [id] => 20151116 [name] => peter 2 [department] => [position] => [rate] => 300 [date_added] => 2017-07-26 09:31:44 ) [20160410] => array ( [auto_id] => 80 [id] => 20160410 [name] => john 2 [department] => [position] => [rate] => 400 [date_added] => 2017-07-26 09:31:48 ) )
any appreciated. thank you.
here need change
$final = array(); foreach($users_array $value){ $final[$value["id"]] = $value; } echo "<pre>"; print_r($final);
Comments
Post a Comment