php - Loop through a JSON decoded array -
php - Loop through a JSON decoded array -
i using randonuser api generate dummy images. api returns json have used json_decode decode , using print_r, got array below:
array ( [results] => array ( [0] => array ( [user] => array ( [gender] => male [name] => array ( [title] => mr [first] => dwight [last] => evans ) [location] => array ( [street] => 6822 hunters creek dr [city] => fresno [state] => vermont [zip] => 63409 ) [email] => dwight.evans44@example.com [username] => ticklishostrich542 [password] => ebony [salt] => 4xuaijmh [md5] => 648f472ff152a194c410d774ff9a4b9d [sha1] => f23cc7ffd2b8980d10de86bccc85068ecf9b7b45 [sha256] => fec06f7df352a06aab9c30af9d7ab9b5b81dc0bd6b7567b59fba1a731dea6bba [registered] => 1129218274 [dob] => 409533355 [phone] => (797)-563-6160 [cell] => (200)-718-4014 [ssn] => 213-46-5200 [picture] => array ( [large] => http://api.randomuser.me/portraits/men/98.jpg [medium] => http://api.randomuser.me/portraits/med/men/98.jpg [thumbnail] => http://api.randomuser.me/portraits/thumb/men/98.jpg ) [version] => 0.4.1 ) [seed] => cf744a697a08f256 ) . .. ..... , on. i need large key value under parent picture. how loop through using foreach statement?
just access would:
$data = json_decode('that json string', true); foreach($data['results'] $value) { echo $value['user']['picture']['large']; } php arrays json
Comments
Post a Comment