Php 如何替换。。。在一个单词之间,一部分是数字,另一部分是';智力?
如果一个单词的一部分是数字,另一部分是int,我怎么能在单词之间加一个空格呢?像这样:Php 如何替换。。。在一个单词之间,一部分是数字,另一部分是';智力?,php,string,replace,Php,String,Replace,如果一个单词的一部分是数字,另一部分是int,我怎么能在单词之间加一个空格呢?像这样: $string = "this is a 2000px height photo"; $string = preg_replace('???',' //1',$string); echo $string; //this is a 2000 px height photo 有人能帮我吗?谢谢 $string = preg_replace('/(\d+)([[:alpha:]]+)/', '$1 $2', $s
$string = "this is a 2000px height photo";
$string = preg_replace('???',' //1',$string);
echo $string; //this is a 2000 px height photo
有人能帮我吗?谢谢
$string = preg_replace('/(\d+)([[:alpha:]]+)/', '$1 $2', $string);
匹配任何数字\d+
匹配任何字母([[:alpha:]+
是错误的,因为匹配字母和数字:\w+
调用拆分数字-例如,“100”变为“10 0”)preg_replace()