是否有一行方法来组合字符串的第一个和最后一个字符?
I tried (without success):
$title = "IncredibleTitle";
$title_characters = (mb_substr($title, 0, 1, 'UTF8')) && (mb_substr($title, 0, -1, 'UTF8'));
- 使用
.
句点字符进行连接 - 要获得最后一个字符,第二个参数必须为-1,第三个参数将为值1或长度。参见
mb_substr
片段:
<?php
$title = "IncredibleTitle";
$title_characters = (mb_substr($title, 0, 1, 'UTF8')) . (mb_substr($title, -1, 1, 'UTF8'));
echo $title_characters;
<<p>在线演示/strong>