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 ~~ ------ Solution ------------------ $ s18 ℃ ~ 8 deg C 18 deg C ~ 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
)
)