php - how to replace ... between a word where one part is numeric the other is'int?
238
how can i put a space between a word where one part is numeric the other is'int? like so:
$string = "this is a 2000px height photo";
$string = preg_replace('???',' //1',$string);
echo $string; //this is a 2000 px height photo
can someone help me? thanks!
Answer
Solution:
\d+
matches any digit[[:alpha:]]+
matches any letter (\w+
is wrong because matches letters and digits: thepreg_replace()
call splits numbers - e.g. '100' becomes '10 0')