PHP 字符串剥离并存储



我有一个很长的字符串,我希望删除从第一个"-"开始的所有内容并保存其余部分。我已经尝试过 rtrim,但这不起作用。可以图爆炸,所以行不通

substr()strpos()一起使用。

$str = "3568206020-1201103628-13107292-0001";
//extract the substring from start to the first occurrence of the character `-`.
$str = substr($str, 0, strpos($str, "-"));

输出 - 3568206020

最新更新