Jump to content

[SOLVED] Multidimensional Arrays = retreiving index as text


PC Nerd

Recommended Posts

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.