获得逗号分隔字符串的第一个值 [英] Get first value of comma separated string
本文介绍了获得逗号分隔字符串的第一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找摆脱逗号分隔字符串的第一个值最快/最短路径,在线
I'm looking for the quickest/shortest way to get the first value from comma separated string, in-line.
我能做的最好的就是
$string = 'a,b,c,d';
echo "The first thing is " . end(array_reverse(explode(',', $string))) . ".";
但我觉得这是过度和多余的。有没有更好的办法?
but I feel that's excessive and redundant. Is there a better way?
推荐答案
如何
echo reset(explode(',', 'a,b,c,d'))
这篇关于获得逗号分隔字符串的第一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文