title: array set as a column name from an array using php mysql
body: <p>I have an foreach loop that is creating a table with new column names from an array collected from a site. At the moment only the first element of the array is being set as a column name, can someone help? </p>
  
  <p>H
  Here is my code:</p>
  
  <pre><code>&lt;?php
  include 'simple_html_dom.php';
  include 'connection.php';
  
  function getsquad($url, $tablename){
  
  $html = file_get_html($url);
  
  $player_fromsite = array();
  
  $space = ' ';
  $replacespace = '_';
  
  $player = array();
  
  foreach($html-&gt;find('td[align=left]') as $element) {
     if ($element-&gt;children(0)) { // work only when children exists
            array_push($player_fromsite ,$element-&gt;children(0)-&gt;innertext);
     }
  }
  
  //$player[] = str_replace($space, $replacespace, $player_fromsite);
  //unset($player_fromsite);
  
  $length = count($player);
  
  foreach($player_fromsite as $player_name) {
    mysql_query("CREATE TABLE " . $tablename . "(" . str_replace($space, $replacespace,     $player_name) . " VARCHAR(30))") or die(mysql_error());   
  }
  
  echo "Table Created!";
  
  }
  
  $Squad = new squad();
  $Squad-&gt;getsquad('site', 'Ars');
  
  ?&gt;
  </code></pre>
  
  <p>any spaces are replace with a "_", in the foreach loop</p>