Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有$word = "big words";
$word = "big words";
我怎么能只保留前6个字母,所以它变成:
$word = "big wo";
(在 PHP 中)
substr,它实际上在几乎所有有字符串的语言中都有。
substr
子字符串函数是您需要的:
substr($word, 0, 6);