A Simple PHP Array Manipulation

Posted by Ygam on Stack Overflow See other posts from Stack Overflow or by Ygam
Published on 2010-03-29T04:40:08Z Indexed on 2010/03/29 4:43 UTC
Read the original article Hit count: 447

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about php

Related posts about array-manipulation