Reputation: 11
I did a json_decode
and when I var_dump
the results variable I get this below.
I have bold the value I am trying to extract but I simply cannot figure out the levels of the associative array to grab that value.
Any help would be much appreciated.
array(2) {
["data"]=> array(16) {
["expiration_schedule"]=> array(0) { }
["last_name"]=> string(11) "johnsonwill"
["loyalty_tier_name"]=> string(6) "Silver"
["uid"]=> string(20) "**[email protected]**"
["dob"]=> string(10) "10/22/1981"
["referrer_email"]=> string(0) ""
["loyalty_tier_id"]=> string(10) "zrl_silver"
["first_name"]=> string(4) "Kyle"
["loyalty_enroll_time"]=> string(10) "02/06/2018"
["available_points"]=> int(50)
["referral_code"]=> string(8) "FJWKAWFHWA"
["redeemed_points"]=> int(0)
["awarded_points"]=> int(50)
["has_opted_out"]=> bool(false)
["user_email"]=> string(20) "[email protected]"
["pending_points"]=> int(0)
}
["success"]=> bool(true)
}
Upvotes: 0
Views: 44
Reputation: 23
What you have is a multidimensional array. If your array name is $test[], you would access that value in this way:
echo $test["data"]["uid"];
See the full implementation here:
$data = array(
"expiration_schedule" => array(),
"last_name" => "johnsonwill",
"loyalty_tier_name" => "Silver",
"uid" => "[email protected]",
"dob" => "10/22/1981" ,
"referrer_email" => "",
"loyalty_tier_id" => "zrl_silver",
"first_name" => "Kyle" ,
"loyalty_enroll_time" => "02/06/2018" ,
"available_points" => 50,
"referral_code" => "FJWKAWFHWA" ,
"redeemed_points" => 0,
"awarded_points" => 50,
"has_opted_out" => false,
"user_email" => "[email protected]" ,
"pending_points" => 0
);
$success = true;
$test = array("data" => $data, "success" => $success);
echo $test["data"]["uid"];
Upvotes: 1