我生成了这个数组:
代码:
$user_info = file_get_contents('http://localhost/rest-server/webservice/api.php?action=get_user&id='.$_GET["id"]);
$user_info = json_decode($user_info, true);
print_r($user_info);
输出:
Array ( [0] =>
Array ( [user_info] =>
Array ( [id] => 12
[first_name] => Test1
[last_name] => User1
[email] => user1@example.com
[country] => ABC
[city] => XYZ
)
)
)
我怎样才能使用这个数组?这样我就可以像这样获取这些数据:`$user_info['first_name'];
我也想在数组上为多个记录放置一个 While 循环,如下所示:
Array ( [0] => Array ( [user_list] => Array ( [id] => 12 [first_name] => Test1 [last_name] => User1 [email] => user1@example.com [country] => ABC [city] => XYZ ) ) [1] => Array ( [user_list] => Array ( [id] => 13 [first_name] => Test2 [last_name] => User2 [email] => user2@example.com [country] => XYZ [city] => ABC ) ) )