Re: how call a variable in a text

From: Date: Thu, 22 Oct 2009 06:53:52 +0000
Subject: Re: how call a variable in a text
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-299183@lists.php.net to get a copy of this message
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

« previous php.general (#299183) next »