Home >Backend Development >PHP Tutorial > 18℃~八℃用正则提取出最低温度并转换成整型应该?

18℃~八℃用正则提取出最低温度并转换成整型应该?

WBOY
WBOYOriginal
2016-06-13 12:56:31872browse

18℃~8℃用正则提取出最低温度并转换成整型应该???
最低温度有时是两位数字有时是一位数字....

是不是因为℃是特殊字符的原因

strrev()倒转字符串然后用floatrev()结果提取出的是0

求解~~


------解决方案--------------------
$s='18℃~8℃';<br />
preg_match('/~([\d-]+)/',$s,$m);<br />
echo $m[1];

------解决方案--------------------
引用:
那请问版主....要提取出后面的那个温度数字...要怎么提取
preg_match_all('/[-+\d.]+/', '18℃~8℃', $t);<br />
print_r($t);<br />
Array
(
    [0] => Array
        (
            [0] => 18
            [1] => 8
        )

)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn