开发者

Truncate Output of Field Php

开发者 https://www.devze.com 2023-04-06 04:06 出处:网络
I have a call 开发者_如何学编程to the database for this row: echo \"{$row[\'uLName\']}\"; This would output for example say : \"Smith\"

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

精彩评论

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

关注公众号