Need help with understanding and fixing a multidimensional array

I'm creating a dynamic equivalent of a javascript menu.  I've got the top tabs worked out but was wanting to put the sub menus into a multidimensional array.  I've got it so long as it's static but as soon as I plug it into the loop, it either gives back the word 'array' or gives me an error about not using a string offset as an array - and I"m having trouble figuring out why that is the case.

There are only two elements I'm pulling back - the name of the tab, which is obviously a string and the recordID which will be an integer.  The code below is part my code and part example I found on the web.  Since the example worked, I started reverse-engineering it to add my database code.  Everything worked statically - but that only gave me information on the very last tab.  To build the whole thing, I need to put it in a loop, build an array of the arrays and then take that and build out the sub-navigation.  Once I put the working static code into the array, that's when I got the message about using a string offset.

Many thanks in advance for all your help.
//PHP LOOP FOR BUILDING INITIAL ARRAY
while(odbc_fetch_row($result)) {								
$tempArray = array("".odbc_result($result,'TabName')."","".odbc_result($result,'TabID')."", 15);
$shop .= array($tempArray);
}

//OUTPUT TEST FOR MULTIDIMENSIONAL ARRAY
echo "Tab Name: ".$shop[0][0]." Tab ID: ".$shop[0][1]." -- Ignore ".$shop[0][2]."<br />";
echo "Tab Name: ".$shop[1][0]." Tab ID: ".$shop[1][1]." -- Ignore ".$shop[1][2]."<br />";
echo "Tab Name: ".$shop[2][0]." Tab ID: ".$shop[2][1]." -- Ignore ".$shop[2][2]."<br />";

Open in new window

saabStoryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StingRaYCommented:
To push something into an array, use [] instead of .

//PHP LOOP FOR BUILDING INITIAL ARRAY
while(odbc_fetch_row($result)) {                                                                
$tempArray = array("".odbc_result($result,'TabName')."","".odbc_result($result,'TabID')."", 15);
$shop[] = array($tempArray);
}

Open in new window

0
StingRaYCommented:
And I'd be better if you assign an empty array to $shop before entering the loop

//PHP LOOP FOR BUILDING INITIAL ARRAY
$shop = array();
while(odbc_fetch_row($result)) {                                                                
$tempArray = array("".odbc_result($result,'TabName')."","".odbc_result($result,'TabID')."", 15);
$shop[] = array($tempArray);
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
saabStoryAuthor Commented:
Excellent - many thanks.  The ultimate goal of all this is create a universal nav for all our sites where all I have to feed in is the database name and table name and a function builds the nav on the fly.  I'm almost there thanks to this.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.