note 40527 deleted from function.implode by nlopess
| From: | nlopess@php.net | Date: | Sat, 06 Mar 2004 20:18:37 +0000 |
| Subject: | note 40527 deleted from function.implode by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66356@lists.php.net to get a copy of this message | ||
Note Submitter:
----
why so long?
<?php
/*
* Returns a string with imploded array-elements like ?key1=value1&key2=value2
* if array is empty or no array, it will return an empty string
*/
function httpimplode($aryInput, $quma = 1)
{
if (!is_array($aryInput) or count($aryInput)=0) return ''; //comment this line and
strings, ints, etc are returned as "0=$aryInput"
foreach ( (array)$aryInput as $key => $value ) $aryOutput[] = urlencode($key) . '=' .
urlencode($value);
return (($quma)?('?'):('')) . implode('&', $aryOutput);
}
?>