鍍金池/ 問答/PHP  數(shù)據(jù)庫  HTML/ PHP怎么去除數(shù)組兩邊的引號(hào),返回?cái)?shù)組

PHP怎么去除數(shù)組兩邊的引號(hào),返回?cái)?shù)組

如圖,怎么去隊(duì)兩邊的引號(hào),返回?cái)?shù)組格式的數(shù)據(jù)

圖片描述

回答
編輯回答
眼雜

$str = '{"aa":" [[123123,123123123],[123123123,123123],[123,123123]]"}';
// 先轉(zhuǎn)一次碼農(nóng)宅
$arr = json_decode($str,true);

print_r(trim($arr['aa']));

2017年8月23日 15:06
編輯回答
未命名

trim($str, '[]')

2018年6月8日 13:57
編輯回答
只愛你

你可能得用正則處理下,提取里邊所有的[xxxx,yyyyy]這樣的字符過遍json_decode,然后再push到一個(gè)新聲明的數(shù)組里。

2017年6月30日 08:45
編輯回答
不二心

你是不是少了一個(gè)json_decode?

2018年3月31日 00:38
編輯回答
情已空

我的眼睛如果沒有看錯(cuò)的話,里面的應(yīng)該是一個(gè)json字符串,只是多了空格.按照我的思路應(yīng)該是這樣子的.

// 測(cè)試的json_str
$str = '{"aa":"  [[123123,123123123],[123123123,123123],[123,123123]]"}';
// 先轉(zhuǎn)一次
$arr = json_decode($str,true);
// 然后在去除空格在轉(zhuǎn)一次
$data = json_decode(trim($arr['aa']),true);
print_r($data);
2018年5月7日 14:47