|
Posted by Rik on 01/25/07 13:35
On Thu, 25 Jan 2007 14:13:50 +0100, Nick Wedd <nick@maproom.co.uk> wrote=
:
> This code
> $cn =3D $ct[$k];
> print "<a name=3D'$ct[$k]'>$continentname[$cn]</a>\n";
> works, and prints something like <a name=3D'af'>Africa</a>
>
> But if I try to simplify it, to
> print "<a name=3D'$ct[$k]'>$continentname[$ct[$k]]</a>\n";
> I get a syntax error
> unexpected '[', expecting ']'
>
> So what is the correct way to write something like $a[$b[$c]] ? I ha=
ve
> tried adding extra {} and '' here and there, so far without success.
Curly braces should work. Tried & tested:
<?php
$bar =3D 'bar';
$foo[$bar] =3D 'baz';
$foz['baz'] =3D 'success';
echo "{$foz[$foo[$bar]]}";
?>
So use print "<a name=3D'$ct[$k]'>{$continentname[$ct[$k]]}</a>\n";
-- =
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse =
possible errors and weird content. *
Navigation:
[Reply to this message]
|