将基本数组转换为PHP数组

将基本数组转换为PHP数组,php,arrays,Php,Arrays,我有一个数组,我拉它看起来像这样: [157966745275000035343192565305328212] 我该如何将这个“字符串”转换成一个PHP数组,然后再对其进行操作。PHP explode就是为此而构建的 $result=explode(',',$input)PHP explode就是为此而构建的 $result=explode(',',$input)这看起来像,所以您可以使用: 这看起来像,因此您可以使用: 用准确的密码 $string='[157966745,275000353

我有一个数组,我拉它看起来像这样:

[157966745275000035343192565305328212]


我该如何将这个“字符串”转换成一个PHP数组,然后再对其进行操作。

PHP explode就是为此而构建的


$result=explode(',',$input)

PHP explode就是为此而构建的

$result=explode(',',$input)

这看起来像,所以您可以使用:

这看起来像,因此您可以使用:


用准确的密码

$string='[157966745,275000353,43192565,305328212]';
$newString=str_replace(array('[', ']'), '', $string); // remove the brackets
$createArray=explode(',', $newString); // explode the commas to create an array

print_r($createArray);

用准确的密码

$string='[157966745,275000353,43192565,305328212]';
$newString=str_replace(array('[', ']'), '', $string); // remove the brackets
$createArray=explode(',', $newString); // explode the commas to create an array

print_r($createArray);

您有一个要转换为的数组。。。数组?PHP不接受这种格式作为数组,所以是的。这是从哪里来的?它真的是一根绳子吗?如果是这样,你应该重命名你的问题。你有一个数组,你想转换成。。。数组?PHP不接受这种格式作为数组,所以是的。这是从哪里来的?它真的是一根绳子吗?如果是这样的话,你应该重新命名你的问题。方括号呢?方括号呢?啊,你走的路很容易+1很好用。应该意识到它可以被解释为JSON。Thanks@Switz:不客气。请注意,只有当您有数值时,这才有效。字符串值必须用双引号括起来。啊,你走的路很容易+1很好用。应该意识到它可以被解释为JSON。Thanks@Switz:不客气。请注意,只有当您有数值时,这才有效。字符串值必须用双引号括起来。现在已修复。谢谢你的注意,现在修好了。谢谢你的注意。
$string='[157966745,275000353,43192565,305328212]';
$newString=str_replace(array('[', ']'), '', $string); // remove the brackets
$createArray=explode(',', $newString); // explode the commas to create an array

print_r($createArray);
$s = "[157966745,275000353,43192565,305328212]";

$matches;
preg_match_all("/\d+/", $s, $matches);

print_r($matches);