note 73900 deleted from ref.array by bobby

From: Date: Fri, 16 Mar 2007 14:50:39 +0000
Subject: note 73900 deleted from ref.array by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124517@lists.php.net to get a copy of this message
Note Submitter: alishahnovin at hotmail dot com ---- If you need an array to implode to strings, but need the quotes: I had a string like this: <?php $s = "1,2,3,4,5"; ?> No control over this. That's what the string looks like. And needed this to be outputted like so: "1","2","3","4","5" Here's what I did: <?php $s = "1,2,3,4,5"; echo string_to_strings($s); function string_to_strings($s) { return substr(array_to_string(array_reverse(explode(",", $s))),0,-1); } function array_to_string($a) { if (sizeof($a)!=0) { $r = '"' . array_pop($a) . '",' . array_to_string($a); return $r; } } ?> Anyone know of any other methods?

« previous php.notes (#124517) next »