Hi all,
I have a variable named $holder with a value of "Supreme", what I need to do is grab the first character and make it a variable named $grabbed, so $grabbed would then have a value of "S".
I thought I could do this using fgetc() or maybe fseek(), but I can't find a way to get them to work for me. I know they're intended for when reading from files but it seemed as though they should be usable with a string, but I guess not.
I'd really appreciate any ideas or suggestions on some other commands/functions that might work for doing something like this.
Thanks in advance,
Scott
Grabbing first character of a variable help
Moderator: General Moderators
Code: Select all
<?php
$string = "String";
$grabbed = $string{0};
echo $grabbed;
?>um... nice, didn't know of that.jason wrote:wheee!!!Code: Select all
<?php $string = "String"; $grabbed = $string{0}; echo $grabbed; ?>