/**
* net_conv_arrayToURLStr
*
* Converts an array to a url string.
* @param $arr - array to convert to url string.
* @param $prefix - string. If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only.
* @param $arg_separator - arg_separator.output is used to separate arguments, unless this parameter is specified, and is then used.
* Credit: mqchen at gmail dot com
* @return string.
*/
function net_conv_arrayToURLStr($arr,$prefix=null,$arg_separator=null){
if(!function_exists('http_build_query')){
$s = http_build_query($arr, $prefix, $arg_separator);
}
else{
$ret = array();
foreach((array)$arr as $k => $v) {
$k= urlencode($k);
if(is_int($k) && $prefix != null) {
$k = $prefix.$k;
};
if(!empty($key)) {
$k = $key."[".$k."]";
};
if(is_array($v) || is_object($v)) {
array_push($ret,arrayToURLStr($v,"",$arg_separator,$k));
}
else {
array_push($ret,$k."=".urlencode($v));
};
};
if(empty($sep)) {
$sep = ini_get("arg_separator.output");
};
$s = implode($sep, $ret);
}
return $s;
}
PHP and javascript snippets you can copy and paste.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(71)
-
▼
March
(25)
- net_get_HTMLDescriptionFromCode($HTMLCode)
- net_increment_ipAddress($iPAddress)
- sec_remove_emailInjectionChars($str)
- str_get_textBetween($start,$end,$str)
- str_remove_doubleQuotes($str)
- str_remove_Quotes($str)
- ajax request
- str_remove_singleQuotes($str)
- str_explode_strAssoc($separator,$assignSeparator,$...
- str_get_strlenmb($s)
- str_get_substrmb($s,$start,$len)
- ajx_print_r
- str_remove_strFromStart($needle,$haystack)
- file_write($fileName, $data, $mode)
- net_get_remoteFile($path,$method='GET',$timeout=30)
- str_get_pointsBetween($start,$end,$s,$n=0)
- dir_do_dirIteratorCallback($dir,$fn,$params)
- fnc_conv_argsToArray()
- net_conv_urlStringToArray($urlStr)
- net_conv_arrayToURLStr($arr,$prefix,$arg_separator)
- xml_get_isXML($xml)
- str_get_strMatchesEnd($needle,$haystack)
- str_conv_strToLowerCaseArray($separator,$s)
- fnc_wrap($fnc)
- net-get-randomIP()
-
▼
March
(25)
No comments:
Post a Comment