我正在尝试使用 string
从 CC_1中删除最后几个字符。
我有字符串"Scryed (download torrent) - TPB"
我想要输出字符串"Scryed"
,例如
$title_t = "Scryed (download torrent) - TPB";
echo ($title_t) ;
echo "n";
$title = ( rtrim ($title_t, "(download torrent) - TPB") );
echo ($title) ;
给出
Scryed (download torrent) - TPB
Scry
为什么?预期输出为
Scryed (download torrent) - TPB
Scryed
这是因为rtrim
的第二个参数是 list of carne 。不是要修剪的字符串!您应该使用substr
或str_replace
:
$title = substr($title_t, 0, strlen($title_t) - strlen("(download torrent) - TPB"));
或
$title = str_replace("(download torrent) - TPB", "" , $title_t);