Re: echo'ing array contents through reference variable
| From: | Tularis | Date: | Sat, 23 Nov 2002 18:20:02 +0000 |
| Subject: | Re: echo'ing array contents through reference variable | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125735@lists.php.net to get a copy of this message | ||
echo ${$pdag[$n]}; // is also possible in case the [$n] is the index to pdag. Otherwise use this:
echo ${$pdag}[$n];
- Tularis
PS. This is basicly the same thing as Ernest said, but shorter...
Ernest E Vogelsinger wrote:
At 16:50 23.11.2002, -<[ Rene Brehmer ]>- said: --------------------[snip]-------------------- Shouldn'techo($$pdag[$n]);be able to pull the string contents of the array? Or is there some extra needed when using referenced variable? --------------------[snip]-------------------- This is ambiguous: is it "$$pdag" indexed by "[$n]", or is it "$pdag[$n]" dereferenced? If you're using an interim variable you'll get what you need - either use (depends on your data layout which I don't know)$temp = $pdag[$n]; echo $$temp;or$temp = $$pdag; echo $temp[$n];