Reputation: 23
I have a call to the database for this row:
echo "{$row['uLName']}";
This would output for example say : "Smith
"
How do I get this call to just output "S
" or whatever the first letter is of the output using php?
Thanks
Upvotes: 0
Views: 412
Reputation: 270609
A simple call to substr()
:
echo substr($row['uLName'],0,1);
Or by string index, since a string's characters can be accessed by numeric array index.
echo $row['uLName'][0];
Upvotes: 3