Re: why doesn't $books[$val][display] show the value

From: Date: Thu, 09 May 2002 22:25:08 +0000
Subject: Re: why doesn't $books[$val][display] show the value
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-96880@lists.php.net to get a copy of this message
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 >

« previous php.general (#96880) next »