PHP:拆分字符串
如何在 PHP 中通过 . 分隔符分割字符串?例如,如果我有字符串 "a.b",我如何获得 "a"?
How do I split a string by . delimiter in PHP? For example, if I have the string "a.b", how do I get "a"?
推荐答案
explode完成工作:
$parts = explode('.', $string);
您也可以直接将部分结果提取到变量中:
You can also directly fetch parts of the result into variables:
list($part1, $part2) = explode('.', $string);
相关文章