Re: Variable as an index

From: Date: Mon, 22 Dec 2008 09:41:43 +0000
Subject: Re: Variable as an index
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-284951@lists.php.net to get a copy of this message
MikeP schreef: > Hello, > I am trying to output the value of the following:($x is an int incremented > by a for statement. > echo "<tr> > <td width='110' bgcolor='$row_color' nowrap> > '$users[$x][U]'</td> > </tr>"; > > I have tried putting the quotes all over and all I get is: > 'Array[U]'. > > What am I doing wrong. you need to help php understand your 'complex' interpolated var (and I'm assuming the key U is not a constant, so ...: e.g.: echo " foo {$users[$x]['U']} bar "; I wouldn't worry about performance overhead of interpolation as opposed to string concatenation ... fixing and/or caching of the DB query (from which I assume your generating the $users array), if you have a performance issue, will win you orders of magnitude more performance than any string interpolation micro-optimization you might undertake. > Thanks > Mike > > >

« previous php.general (#284951) next »