如何使用PHP解码此Json数组

时间:2016-05-06 23:49:11

标签: php arrays json multidimensional-array

如何使用php解码此json数据以获取单个值。

{"阿尔法":[" A"" B"" C"" d&#34 ;, " E"" F&#34],"β":[" 1"" 2"&#34 ; 3"]," Gamma":[" a"," b"," c"]}

1 个答案:

答案 0 :(得分:0)

php有一个名为json_decode

的函数
$json = '{"Alpha":["A","B","C","D","E","F"],"Beta":["1","2","3"],"Gamma": ["a","b","c"]}';

$json_array = json_decode($json,TRUE); // personally I prefer arrays which the TRUE adds

$alpha = $json_array['Alpha'];

$first_alpha_value = $alpha[0];

printf("A == %s\n",$first_alpha_value);