Friday 29 August 2014

Inserting Multidimensional php array into mysql

<?php_
$ppl = Array
 (
     [0] => Array
         (
             [first] => Keith
             [last] => Armstrong
         )

     [1] => Array
         (
             [first] => Farhan
             [last] => Daya
         )

     [2] => Array
         (
             [first] => Sean
             [last] => Do
         )
 )

foreach( $ppl as &$person ){
  $sql = "INSERT INTO ppl (first, last) VALUES ($person.first, $person.last)";
}
?>

No comments:

Post a Comment