Re: Variable as an index

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

 



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 
> 
> 
> 


-- 
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