Re: Echo array string index?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matt Darby wrote:
I have an array setup as such: *$arr['generated text']='generated number';*

What would be the best way to echo the key in a loop?
Seems pretty easy but I've never attempted...

Thanks all!
Matt Darby

I'm not sure I understand the question.

You could do foreach($arr as $key => $value) { print($key); }.

There are also a number of functions that get the current key on the array's pointer:

http://us2.php.net/manual/en/function.key.php
http://us2.php.net/manual/en/function.array-keys.php

But once again, it really comes down to what exactly it is you want to do...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux