note 51416 added to function.implode

From: Date: Wed, 30 Mar 2005 14:50:32 +0000
Subject: note 51416 added to function.implode
Groups: php.notes 
Request: Send a blank email to php-notes+get-87182@lists.php.net to get a copy of this message
Also quite handy in INSERT statements: <?php // array containing data $array = array( "name" => "John", "surname" => "Doe", "email" => "j.doe@intelligence.gov" ); // build query... $sql = "INSERT INTO table"; // implode keys of $array... $sql .= " (".implode(", ", array_keys($array)).")"; // implode values of $array... $sql .= " VALUES ('".implode("', '", $array)."') "; // execute query... $result = mysql_query($sql) or die(mysql_error()); ?> ---- Manual Page -- http://www.php.net/manual/en/function.implode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51416 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51416&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51416&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51416&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51416&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51416&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51416&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87182) next »