title: php function to return sql results that contain arrays, as an array
body: <p>So im having a problem (obviously). I have the following MySQL table data</p>
  
  <pre><code>7   USER1       1,1,1,10,1      The Guys Team   8,7,13,14,16
  8    USER1      1,1,1,10,1  The Girls Team  7,12,15
  10  USER1       1,1,1,10,1  Dog Team    8,7,14,15
  </code></pre>
  
  <p>I wrote a function to retrieve the data, and return it.</p>
  
  <pre><code>function ShowSetTeams($coach){
      $result = mysql_query("SELECT * FROM `teams` WHERE coach = '$coach'") or trigger_error(mysql_error()); 
      while($row = mysql_fetch_array($result)){ 
          foreach($row AS $key =&gt; $value) { $row[$key] = stripslashes($value); } 
              $id = $row['id'];
              $teamname = $row['teamname'];
              $team = $row['team'];
              $event = $row['event'];
              $push .= array($id, $teamname, $team, $event);
      }
      return $push;
  }
  </code></pre>
  
  <p>When i call the function, as below</p>
  
  <pre><code>$info = ShowSetTeams("USER1");
  </code></pre>
  
  <p>I get this</p>
  
  <pre><code>ArrayArrayArray 
  </code></pre>
  
  <p>I tried echoing $info[0], $info[1], and $info[2], but get this</p>
  
  <pre><code>Arr
  </code></pre>
  
  <p>So each line in the info array, is the result array. I should be able to do $info[0][0] and get the first ID value, from the first result right?</p>
  
  <pre><code>Fatal error: Cannot use string offset as an array
  </code></pre>
  
  <p>Im at a loss. <strong>How can i get to each of the values of the returned arrays?</strong> And more to the point, <em>how could i run a foreach operation on them</em> such as</p>
  
  <pre><code>foreach( $info as $key =&gt; $value){
  $key[0] //ID
  $key[1] //TEAMNAME
  $key[2] //TEAM
  $key[3] //EVENT
  }
  </code></pre>