TicTacTheTech Posted April 14, 2020 Share Posted April 14, 2020 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 array( "account" => array( "login", "register", "logout", "edit", ), "p" => array( "report", ), "array1.0" => array( "array2.0" => array( "array3.0", "array3.1 ), "array2.1", ), 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. Quote Link to comment https://forums.phpfreaks.com/topic/310564-php-loop-through-arrays-withing-arrays/ Share on other sites More sharing options...
gw1500se Posted April 14, 2020 Share Posted April 14, 2020 I'm not sure I understand what you are trying to do. Why would you take a perfectly fine associative array and convert it to such a weird format? Quote Link to comment https://forums.phpfreaks.com/topic/310564-php-loop-through-arrays-withing-arrays/#findComment-1576801 Share on other sites More sharing options...
chhorn Posted April 14, 2020 Share Posted April 14, 2020 you need a recursive function then Quote Link to comment https://forums.phpfreaks.com/topic/310564-php-loop-through-arrays-withing-arrays/#findComment-1576806 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.