我知道要替换我可以使用的空格:
str_replace(' ', ';', $string);
我的问题是...如何只替换第一个空格?
例如:
firstword secondword thirdword
至 firstword;secondword thirdword
最佳答案
preg_replace('/ /', ';', $string, 1)
关于PHP用分号替换第一个空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22860731/