Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. $data = array("A", "B", 9, "12", "D");
  2. $sql  = "INSERT INTO table (f) VALUES";
  3.  
  4. foreach($data as $val) {
  5.     if (is_numeric($val)) {
  6.         $sql .= "($val),";
  7.     } else {
  8.         $sql .= "('$val'),";
  9.     }
  10. }
  11. $sql = substr($sql, 0, -1);
  12.  
  13. print($sql); // INSERT INTO table (f) VALUES('A'),('B'),(9),(12),('D')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement