Jump to content

PHP loop through arrays withing arrays


Recommended Posts

I'm having troubling with trying to create a function to spit out a single array with the following array. I can write it in a away that looks through the arrays manually. 

the results i am trying to generate is that each item in generated array.

Array to convert

    "account" => array(
    "p" => array( 
    "array1.0" => array( 
        "array2.0" => array(

generating the array will look like this


Array ( 
[0] => account 
[1] => account/login 
[2] => account/register 
[3] => account/logout 
[4] => account/edit 
[5] => p 
[6] => p/report 
[7] => array1.0 
[8] => array1.0/array2.0
[9] => array1.0/array2.0/array3.0
[10] => array1.0/array2.0/array3.1
[11] => array1.0/array2.1


The idea is that id generates a single array with combined labels and arrays inside, etc. I just can't figure out how to create a script that will create this array even If I add a new value or array. 


Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.