create recursive array from single dimension array
Posted: Sun May 23, 2010 4:34 pm
Okay, this is going to be hard to explain… it a logical problem.
I have an array (which I obtained from a preg_replace). This array has keys going from 0 to an unknown number.
What I need it to loop for the lenght of the array and create a new multidimensional array of an imbrication by ascending order.
An example will help clarifying:
base array :
final result desired :
I just cannot figure out how to do this, but I pretty sure it's simple. Please help.
I have an array (which I obtained from a preg_replace). This array has keys going from 0 to an unknown number.
What I need it to loop for the lenght of the array and create a new multidimensional array of an imbrication by ascending order.
An example will help clarifying:
base array :
Code: Select all
[0]=>'hello'
[1]=>'how'
[2]=>'are'
[3]=>'you'Code: Select all
['hello']['how']['are']=>'you'