PHP and javascript snippets you can copy and paste.

Tuesday, April 3, 2007

net_convert_arrayToUrlStr($arr)

/**
* Converts an array to url string.
*
* @param object $xpathObj.
* @param object $path.
* @param int $index - defaults to 0.
* @return array.
*/

function net_convert_arrayToUrlStr($arr){

$s = '';

if(is_array($arr) && !empty($arr)){
while(list($key,$val)=each($arr)){
$s .= urlencode($key) . '=' . urlencode($val) . '&';
}

// remove trailing '&'
$s = substr($s, 0, -1);

}


return $s;

}

No comments: