note 57220 deleted from function.implode by hholzgra

From: Date: Thu, 02 Aug 2012 13:17:01 +0000
Subject: note 57220 deleted from function.implode by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189729@lists.php.net to get a copy of this message
Note Submitter: Peter Hopfgartner ---- Correctly initializing all variables, this would become: function implode_with_key($assoc, $inglue = '=', $outglue = '&'){ $return = ''; foreach ($assoc as $tk => $tv) { $return = ($return != '' ? $return . $outglue : '') . $tk . $inglue . $tv; } return $return; } Note, the return value is also well defined if $assoc is empty. Regards

« previous php.notes (#189729) next »