-3

Let me start by saying that i'm sorry if this is a complete noob question.

while using phpStorm, I have an array of $teams and by invoking foreach loop I tried to put each of the array section into an HTML table

here is what I did so far

I am getting cannot use [] for reading, I can't find an answer how to do that properly, thx in advance.

<table>
    <tr>
        <th>Team</th>
        <th>ID</th>
    </tr>

    <?php
        include dirname(__FILE__) . "/stats.php";
        global $teams;

        foreach ($teams['data'] as $team) {
            echo "<tr>" ;
                echo   "<td> $team['name']</td>" ;
                echo   "<td> $team ['id']</td> " ;
            echo "</tr>";
        }
    ?>
</table>
Gumma Mocciaro
  • 1,205
  • 10
  • 24
Yoni hodeffi
  • 103
  • 2
  • 8

1 Answers1

3

To get the string substitution working correct, you have to suround it with {} if it's something more complex than a simple var - especially array access.

 echo "<td> {$team['name']}</td>";
Philipp
  • 15,377
  • 4
  • 35
  • 52