note 104653 deleted from function.implode by danbrown

From: Date: Wed, 29 Jun 2011 15:39:23 +0000
Subject: note 104653 deleted from function.implode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181059@lists.php.net to get a copy of this message
Note Submitter: sgirard AT spokanelibrary DOT org ---- 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

« previous php.notes (#181059) next »