It has to do with precedence (I think).  When inside a double quoted
string PHP evalutes "$books[$val]" *first* and doesn't catch that there's
more to it...

You can do this:

$html.= " Yaddda yadda " . $books[$val][display];

And I think this (or something close to it):

$html.= " Yaddda yadda {$books[$val][display]}";

On Thu, 9 May 2002, Peter J. Schoenster wrote:

> Hi,
>
> I've got an array like the following:
>
>       $books = array(
>               "1572316217" => array(
>                       category        => 'tech',
>                       display         => 'Steve McConnell\'s Software Project 
>Survival Guide',
>                       href            =>
> 'http://www.amazon.com/exec/obidos/ASIN/1572316217/readbrazil07-20',
>                       title           => 'Steve McConnell\'s Software Project 
>Survival Guide',
>                       width           => '71',
>                       height          => '90',
>                       src                     => 
>'/images/1572316217.01.TZZZZZZZ.jpg',
>                       vspace          => '3',
>                       alt                     => 'Steve McConnell\'s Software 
>Project Survival Guide',
>                       hspace          => '3',
>                       comments        => "",
>               ),
>
> $books     = $AfiliateLinkBuilder->get_books();
> srand ((float) microtime() * 10000000);
> $rand_keys = array_rand ($books, 2);
>
> while (list ($key, $val) = each ($rand_keys)) {
>       $display = $books[$val][display];
>
> Why do I have to do this:
>       $display = $books[$val][display];
>
> rather than
>
> $html.= " Yaddda yadda $books[$val][display]";
>
>  $books[$val][display] in the double quotes only shows display. I
> thought that within double quotes I don't use double quotes for
> elements ... ? What's the rule on this. I could do the above in Perl.
>
> Thanks,
>
> Peter
>
>
> -- http://www.readbrazil.com/
> Answering Your Questions About Brazil
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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

Reply via email to