Page 1 of 1
PHP return charicter in a string...
Posted: Mon Mar 27, 2006 1:53 pm
by siefkencp
It's a silly question... sorry.
Ok, How's it done?... I know the position of the string I want to return (but not the value), how do i get it out?
Chris
Posted: Mon Mar 27, 2006 1:54 pm
by hawleyjr
Say you want the letter 'a' in 'car'
Posted: Mon Mar 27, 2006 2:05 pm
by siefkencp
I tried it
Code: Select all
$var = "some value";
$pointer = 3;
$value = $var{$pointer};
print $value;
I get...
Parse error: syntax error, unexpected '{'
Posted: Mon Mar 27, 2006 2:05 pm
by Burrito
also take a look at
substr().
it's not as elegant, but is a nice tool to have in your bag...
Posted: Mon Mar 27, 2006 2:08 pm
by hawleyjr
siefkencp wrote:I tried it
Code: Select all
$var = "some value";
$pointer = 3;
$value = $var{$pointer};
print $value;
I get...
Parse error: syntax error, unexpected '{'
Works for me

Posted: Mon Mar 27, 2006 2:13 pm
by siefkencp
I forgot a "$" ......
geez... every compiler/interpreter is a critic ...
Thanks guys!