note 104653 added to function.implode

From: Date: Tue, 28 Jun 2011 22:40:23 +0000
Subject: note 104653 added to function.implode
Groups: php.notes 
Request: Send a blank email to php-notes+get-181025@lists.php.net to get a copy of this message
Just a note: rustem's approach of 26-Apr-2010 may not be necessary for generating JSON (use json_encode instead) but is useful for generating a string of single-quoted, comma-separated strings for a SQL IN clause. For example: protected function getArrStr($arr=null) { $str = null; if (is_array($arr)) { $str = "'" . implode("','", $arr) . "'"; } return $str; } Now you can do something like: "SELECT * FROM table WHERE column IN (" . $this->getArrStr($my_array) . ")"; If'n you want. -sean ---- Server IP: 69.147.83.197 Probable Submitter: 198.1.37.135 ---- Manual Page -- http://www.php.net/manual/en/function.implode.php Edit -- https://master.php.net/note/edit/104653 Del: integrated -- https://master.php.net/note/delete/104653/integrated Del: useless -- https://master.php.net/note/delete/104653/useless Del: bad code -- https://master.php.net/note/delete/104653/bad+code Del: spam -- https://master.php.net/note/delete/104653/spam Del: non-english -- https://master.php.net/note/delete/104653/non-english Del: in docs -- https://master.php.net/note/delete/104653/in+docs Del: other reasons-- https://master.php.net/note/delete/104653 Reject -- https://master.php.net/note/reject/104653 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181025) next »