KoBa4 Asked:2020-11-12 17:25:41 +0000 UTC2020-11-12 17:25:41 +0000 UTC 2020-11-12 17:25:41 +0000 UTC php 提取括号内的值 772 有漏: $size = "3.80 GB (4075743232 Bytes)" 只需4075743232要从括号中提取,需要理解括号前和里面的值总是不同的。 php 1 个回答 Voted Best Answer KoVadim 2020-11-12T17:35:33Z2020-11-12T17:35:33Z 解决这个问题的最简单方法是使用正则表达式。某处如此 <?php $re = '/\((\d+)[^)]+\)/'; $str = '3.80 GB (4075743232 Bytes)'; if (preg_match_all($re, $str, $matches)) { print_r ($matches); } else { print "ups"; }
解决这个问题的最简单方法是使用正则表达式。某处如此