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.
我对我的英语感到很抱歉,我保证会提高它。
我正在使用 PHP,我有这个: $var = 'word1-word2-word3-34567';
我只想获取最后一个破折号右侧的任何内容,在本例中为“34567”。
谢谢!
让我们猜测它是php:
array_pop(explode('-',$var))
或者
substr($var,strrpos($var,'-')+1)
这应该工作
$words = explode('-', 'word1-word2-word3-34567'); $last_word = $words[count($words) - 1];