十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶(hù) + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專(zhuān)業(yè)推廣+無(wú)憂(yōu)售后,網(wǎng)站問(wèn)題一站解決
// 生成一個(gè)PHP數(shù)組
10年積累的成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶(hù)對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶(hù)得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有獨(dú)山免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
$data = array();
$data['name'] = 'admin';
$data['pwd'] = '123456';
// 把PHP數(shù)組轉(zhuǎn)成JSON字符串
$json_string = json_encode($data);
// 寫(xiě)入文件
file_put_contents('user.json', $json_string);
// 從文件中讀取數(shù)據(jù)到PHP變量
$json_string = file_get_contents('user.json');
// 把JSON字符串轉(zhuǎn)成PHP數(shù)組
$data = json_decode($json_string, true);
// 顯示出來(lái)看看
var_dump($data)
$dataJson = "數(shù)據(jù)"; // 提供數(shù)據(jù)
$data = json_decode($dataJson); // 數(shù)據(jù)按json解析成php數(shù)組
$minuteArr = $data['minute']; // 從數(shù)組中獲取minute數(shù)據(jù)
此時(shí)$minuteArr中存放的就是你要的數(shù)據(jù),但數(shù)組下標(biāo)(鍵)是從0開(kāi)始,如需要從1開(kāi)始,則遍歷$minuteArr修改下標(biāo)(鍵) 或 使用php數(shù)組函數(shù)進(jìn)行快速重構(gòu)。
注:你這問(wèn)題是還沒(méi)入門(mén)的初學(xué)者問(wèn)的問(wèn)題,建議還是多看看書(shū)!...
先使用json_decode()函數(shù)解析成數(shù)組,在用變量等于解析出來(lái)的數(shù)組
$test=json_decode("json數(shù)據(jù)");
輸出 echo $test-key;