aa    [1] => abc) ------解决思路-------------"/>  aa    [1] => abc) ------解决思路-------------">
Home > Backend Development > PHP Tutorial > 转一个数组,该如何处理

转一个数组,该如何处理

WBOY
Release: 2016-06-13 12:08:23
Original
828 people have browsed it

转一个数组
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));
Copy after login
Array<br />(<br />    [awd] => Array<br />        (<br />            [0] => aa<br />            [1] => abc<br />        )<br /><br />)<br /><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template