开发者

Truncate Output of Field Php

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


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜