I've been looking all over for the solution to this problem, but everything I try always returns the same error.
Fatal error: Cannot use object of type stdClass as array
This is the JSON resource I'm trying to access with PHP cURL: https://www.easports.com/iframe/fifa16proclubs/api/platforms/PS4/clubs/36881/members
The issue I'm having is accessing the raw array. I've had success using the following code with objects, but I always have trouble when there is an array involved.
$phpObj = json_decode($json);
if (!is_null($phpObj->raw))
{
$object = $phpObj->raw;
foreach ($object as $obj)
{
echo "<tr id='clubs-search-result'><td class='club-search-name'>" . $obj->name . "</td><td class='blaze-id hidden'>" . $obj->blazeId . "</td><td><button type='button' class='form-button players-search-button red-bg'>Select</button></td></tr>";
}
}
I know that this is not the correct way to access an array, which is what I need help with. I want to be able to access the raw array and then iterate through all the objects inside the array. I've looked at many code examples but nothing seems to be working for my scenario.
The above code works with this resource: http://www.easports.com/iframe/fifa16proclubs/api/platforms/PS4/clubsComplete/United
Only because I'm accessing nested objects and there are no arrays [] involved.
Any help would be appreciated. Thanks!