18 ℃ ~ The minimum temperature is extracted with regular expressions at 8 ℃ and converted to an integer type ??? The lowest temperature is sometimes two digits, sometimes a digit .... is it because deg C is a special character that strrev () reverses the string and uses floatrev () to extract the result that 0 is used to solve the problem ~~ 18 ℃ ~ The minimum temperature is extracted with regular expressions at 8 ℃ and converted to an integer type ???
The lowest temperature is sometimes two digits, sometimes a digit ....
Is it because ℃ is a special character?
Strrev () reverses the string and uses floatrev () to extract 0.
Solution ~~
------ Solution --------------------
$s='18℃~8℃';
preg_match('/~([\d-]+)/',$s,$m);
echo $m[1];
------ Solution --------------------
Reference:
I would like to ask the moderator... how to extract the following temperature number...
preg_match_all('/[-+\d.]+/', '18℃~8℃', $t);
print_r($t);
Array
(
[0] => Array
(
[0] => 18
[1] => 8
)
)