Re: how call a variable in a text

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

 




On Wed, 2009-10-21 at 23:11 +0200, Kim Madsen wrote:

Ashley Sheridan wrote on 2009-10-21 22:56:

Try this though:

<?php

$var = array(array('great','alright'), 'boring');

print "This is $var[0][0].";
Print "This is different from your previous example :-)";

--
Kind regards
Kim Emax - masterminds.dk



Yeah, I just forgot that PHP will correctly work with an array to a
depth of 1 inside of a string. Much like the above advice, I'd taken to
always using {} for arrays inside of strings, although not for strings
inside of strings unless I needed non-white-space text to immediately
follow said string. Would make more sense if I used the braces for
everything, but nobody has ever accused me of making too much sense
before!

Thanks,
Ash
http://www.ashleysheridan.co.uk




This will also work (shell like style):

print "Test: ${var[0]}";

but this won't based on the same principle you mention above:

print "Test: ${var[0][0]}";

--
Thodoris


[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