aa    [1] => abc) ------解决思路-------------"/>  aa    [1] => abc) ------解决思路-------------">

Home >Backend Development >PHP Tutorial >转一个数组,该如何处理

转一个数组,该如何处理

WBOY
WBOYOriginal
2016-06-13 12:08:23829browse

转一个数组
string(73) "awd:[\"aa\",\"abc\"]"
转成下面这个
Array
(
    [0] => aa
    [1] => abc

------解决思路----------------------
你给出的数据显然不符合 string(73) 这个信息

$s = "awd:[\"aa\",\"abc\"]";<br />$s = preg_replace('/(\w+):/', '"$1":', $s);<br />print_r(json_decode('{' . $s . '}', 1));
Array<br />(<br />    [awd] => Array<br />        (<br />            [0] => aa<br />            [1] => abc<br />        )<br /><br />)<br /><br />

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