I have an array that looks like this:
array(1) {
["brookybear"]=> array(5) {
["id"]=> int(20217894)
["name"]=> string(10) "Brookybear"
["profileIconId"]=> int(603)
["summonerLevel"]=> int(30)
["revisionDate"]=> float(1397388011000)
}
}
when i var_dump(); it. I'm trying to use a foreach loop to take the "name" value out of it. However, when I echo it, I only get "B" as the output, and not the full Brookybear.
Here is my foreach loop:
$url="APIURL";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
$array = json_decode($result, true);
foreach($array['brookybear'] as $champs)
{
echo $champs['name'];
}
var_dump($champs)shows inside the loop?curlandjsonstuff going on - are you sure the array you show is the one you get fromjson_decode($result, true)? If so, you should trim your question down a bit.