The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hope someone is able to help me out here
As suggested by the title, I'm using a 4 dimensional array to hold category information (hierarchially). I know the right data is in the right places in the array because I can do a print_r($array) statement and it shows it correctly.
But here is the dilemma:

I'm using a pair of loops to get down to the fourth level in the array:

I'm only using a $val1 variable - not $vall.
Both while() statements are just using $val1.
I also tried it with an empty variable and it came up with an error about not being an array, which confuses me even more. Surely that means that the variables I'm using are arrays also?

lol so is mine, that's why my method above failed
No I didn't think about doing a class for it, and looking back it might have been a good idea. Though for now I'm happy because it works and is fairly efficient If I ever redevelop that function (not likely for a while ) then I'll see about doing a class.