Forum Moderators: coopster

Message Too Old, No Replies

reformulate new array

         

PHPycho

5:41 am on Nov 11, 2009 (gmt 0)

10+ Year Member



Reformulate new array

I had the following array:
array(
'title_1' => 'some value',
'link_1' => 'some value',
'title_2' => 'some value',
'link_2' => 'some value',
'title_3' => 'some value',
'link_3' => 'some value',
...
)

I want to convert this array as follow:
array(
array('title_1' => 'some value',
'link_1' => 'some value'),
array('title_2' => 'some value',
'link_2' => 'some value'),
array('title_3' => 'some value',
'link_3' => 'some value'),
...
)

So that i can group items and loop easily.

Thanks

coopster

2:58 pm on Nov 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The logic requirements here are going to be cause for a control structure such as foreach() to iterate your array and restructure. It would probably be easier to do when the array is originally created though so if you are pulling the information from a database, do a little logic processing there instead when you first build the array.