PHP session array output

Hi,

I have a mysql query. I fetch the results using while loop. In the while loop, i make a session array so i can use in other pages. Here is the session array.

$_SESSION['perm_sub_depts'][$counter] = array($deptRow['title'], $subRow['titlle']);

When I output this using print_r, i get the following:

Array ( [1] => Array ( [0] => Backend Users [1] => My Account )

[2] => Array
(
[0] => Backend Users
[1] => Demo Users
)

[3] => Array
(
[0] => CMS
[1] => Article Category
)

[4] => Array
(
[0] => CMS
[1] => Article Content
)

[5] => Array
(
[0] => CMS
[1] => Albums
)

[6] => Array
(
[0] => CMS
[1] => Photos
)

[7] => Array
(
[0] => e-Commerce
[1] => Prints
)

)

This is how I want it to display:

Backend Users - My Account - Demo Users CMS - Article Category - Article Content - Albums - Photos e-Commerce - Prints

I tried echoing this in for loop, but I keep on getting this:

1: Backend Users My Account Demo Users Article Category Article Content Albums Photos Prints 2: CMS My Account Demo Users Article Category Article Content Albums Photos Prints 3: e-Commerce My Account Demo Users Article Category Article Content Albums Photos Prints

Help anyone???

It looks like you’re not filtering on which item goes into which category. I’m thinking you’re looking at nested loops right now, which can be pretty complex to debug. Could you show us the relevant code that produces the current outcome?

Sponsor our Newsletter | Privacy Policy | Terms of Service