1

I've fetched data from Riot Games API servers that supposes to give me all my champions points I've played with.

try {
    $poeni = $api->getChampionMasteries($sId);
}

catch {
    die("Failed." . $ex->getMessage());

Basically, now I have array elements that I'm trying to iterate with foreach loop, and put in HTML table.

<?php foreach ($poeni as $po): ?>
        <tr>
            <td><?=$po->championId?></td>
            <td><?=var_dump($po->name . ", " . $po->title)?></td>
            <td><?=$po->championLevel?></td>
            <td><?=$po->championPoints?></td>
            <td><?=$po->chestGranted ? 'Da' : 'Ne'?></td>
            <td><?=$po->championPointsUntilNextLevel?></td>
        </tr>
<?php endforeach; ?>

I'm no familiar with PHP, so pretty much I'm learning it. Apparently, my $po->name . ", " . $po->title is object, not an array so error I'm getting is Notice: Trying to get property 'name' of non-object in. I tried to access it's object with $po[0]->{'name'}, but getting error cannot use object as array. Everything else is working besides this.

dh4ze
  • 449
  • 1
  • 5
  • 10

0 Answers0