A Simple PHP Array Manipulation
- by Ygam
Hi guys! how would you turn this array:
array(
0 => Title1,
1 => Title2,
3 => Address1,
4 => Address2,
)
to this array:
array (
0 => array(
'title' => 'Title1'
'address' =>'Address1'
),
1 => array(
'title' => 'Title2',
'address' => 'Address2'
)
);
when you were initially given
$_POST['title'] = array('Title1', 'Title2);
$_POST['address'] = array('Address1', 'Address2');
which when merged would give you the first array I have given
I was able to solve this via a high level Arr:Rotate function in Kohana framework, along with Arr::merge function but I can't quite understand the implementation. Please help