note 99336 deleted from function.implode by danbrown

From: Date: Wed, 11 Aug 2010 17:53:52 +0000
Subject: note 99336 deleted from function.implode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171576@lists.php.net to get a copy of this message
Note Submitter: rcha at cubistcode dot com ---- I improved the wrap_each function from below to quote items with embedded delimiters as needed. I used http://creativyst.com/Doc/Articles/CSV/CSV01.htm as reference. <?php function wrap_each(&$item) { // quote item if it contains whitespace, delimiters or is empty if ( (preg_match('/[\s,"]/',$item) !=0 ) || ($item == "") ) { $item = str_replace('"','""',$item); $item = "\"$item\""; } } array_walk($array, 'wrap_each'); $array_csv = implode(",", $array); ?>

« previous php.notes (#171576) next »