【发布时间】:2022-01-19 11:57:07
【问题描述】:
我想用字符串之外的公式计算字符串,有时我得到两个数字用空格分隔的字符串,我的公式只是计算字符串中的第一个数字。
$string = "225cm x 70cm";
$outputString = preg_replace('/[^0-9]/ ', ' ', $string);// output here is string(12) "225 70 "
$inches = intval($outputString) * 0.39370;
$inches_pre = round($inches / 0.5) * 0.5; // output here is just 85 instead of string "85.5 27.5"
【问题讨论】: