删除周围的引号 json 文件,仅数字,php preg_replace

Remove surrounding quotes json file, numbers only, php preg_replace

发现一些 C 或其他语言的解决方案,但在 php 没有用。

我需要替换(大)json 文件中的所有数字,以避免数字在 javascript.

中使用时被视为字符串

例如:

[["Alt","128","36.00","36.00","test" .....]]

我想要的:

[["Alt",128,36.00,36.00,"test" .....]]

已经尝试了几种方法,但我不是怀孕专家,像这样的东西不起作用:

$sOutput = preg_replace('/^(\'[0-9]\'|"([0-9])")$/', '', $sOutput );
die( $sOutput );

我怎样才能实现我的目标?

$re = '/\"([0-9.]+)\"/m';
$str = '[["Alt","128.12","36.00","36.00","test" ....., "123.45"]]';
$subst = '';

$result = preg_replace($re, $subst, $str);

echo "The result of the substitution is ".$result;