PC Nerd Posted July 29, 2007 Share Posted July 29, 2007 Hi, Ive got a 2 dimsneional Array eg: $Array['1'][0] $Array['1'][1] $Array['2'][0] $Array['2'][1] $Array['3'][0] $Array['3'][1] What i want to do is have something, the looks like: foreach($Array as $Field => $Value) { } Now how can i reteive the actial index ( first index).? thanks Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 29, 2007 Share Posted July 29, 2007 By index, are you referring to the key? It would be stored in $Field, wouldn't it? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted July 29, 2007 Author Share Posted July 29, 2007 ok, i think ive fixed it, thankx though for the record... Field would contain the Array object. basically, im looking for a way to actually pront out the variable/array name.... eg: $variable = "test"; echo $variable; = "test" i want a way for it to output: "variable" or whaterver thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted July 29, 2007 Share Posted July 29, 2007 for the record... Field would contain the Array object. you must be running a different php from the rest of us <?php $Array['1'][0] = 'a'; $Array['1'][1] = 'b'; $Array['2'][0] = 'c'; $Array['2'][1] = 'd'; $Array['3'][0] = 'e'; $Array['3'][1] = 'f'; foreach ($Array as $Field => $val) echo $Field. '<br>'; ?> gives --> 1 2 3 Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted July 29, 2007 Author Share Posted July 29, 2007 hmmm, ok, thankx Quote Link to comment 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.