18 ℃ ~ What should I do if I use regular expressions to extract the lowest temperature and convert it to an integer type?

Source: Internet
Author: User
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
)

)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.