|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Splitting an array into another multi-array
Hi guys, Lets say that I have an array with 11 elements like the diagram of the array below: $full_array = array( ['1'] => 'abc', ['2'] => 'cde', ['3'] => 'ghf', ['4'] => '12g', ['5'] => 'gh5', ['6'] => '878', ['7'] => '14y', ['8'] => 'd56', ['9'] => 'hj6', ['10'] => '9h7', ['11'] => 'o89' ); now with the array above I would like to now split it up and store it in another array, "an array of arrays" but there should be "no more than 3 elements" in each array (sub-array) when it's split up, example below: $split_array = array( [0] => array(['1'] => 'abc', ['2'] => 'cde', ['3'] => 'ghf') [1] => array(['4'] => '12g', ['5'] => 'gh5', ['6'] => '878') [2] => array(['7'] => '14y', ['8'] => 'd56', ['9'] => 'hj6') [3] => array(['10'] => '9h7', ['11'] => 'o89') ); What is the easiest wway to accomplish the above task. An example would be nice! ![]() Thank you! |
|
#2
|
|||
|
|||
|
PHP Code:
I haven't tested this code, so there might be an off-by-one error, but the logic should be correct. Last edited by Robo : November 7th, 2002 at 08:17 AM. |
|
#3
|
|||
|
|||
|
thanks
thanks i'll give it a try
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Splitting an array into another multi-array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|