我有像下面这样的文字,我需要删除逗号和‘(单引号)或符号前后的空格(单引号)。
$text = "'game', ' open world', ' test rpg'"预期结果
$text = "'game','open world','test rpg'"我试过这一次,但是去掉了所有的空间
$tested = preg_replace('/\s+/', '', $text);发布于 2018-07-10 06:28:51
echo preg_replace('/\s+?\'\s+?/', '\'', $text);发布于 2018-07-10 06:27:42
发布于 2018-07-10 06:28:50
备选案文1:
$text = explode("', ' ",$text);
$text = implode("','",$text);备选案文2:
$text = str_replace("', ' ","','",$text)https://stackoverflow.com/questions/51258382
复制相似问题