I have an array items with some arrays. Now I want to add an array item_optional to the top of array items.
This is what I've tried, but I think this is not correct:
$item_optional = array(
'harry' => array('name'=>'test1', 'code'=>1697, 'hmp'=>'x1')
);
$items = array(
'denise' => array('name'=>'test2', 'code'=>2697, 'hmp'=>'x2'),
'mike' => array('name'=>'test3', 'code'=>3697, 'hmp'=>'x3'),
'richard' => array('name'=>'test4', 'code'=>4697, 'hmp'=>'x4')
);
array_unshift($items, $item_optional);
The output should be:
$items = array(
'harry' => array('name'=>'test1', 'code'=>1697, 'hmp'=>'x1'),
'denise' => array('name'=>'test2', 'code'=>2697, 'hmp'=>'x2'),
'mike' => array('name'=>'test3', 'code'=>3697, 'hmp'=>'x3'),
'richard' => array('name'=>'test4', 'code'=>4697, 'hmp'=>'x4')
);