Advertisements

_http_build_query

Definition:
function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {}

Parameters

  • $data
  • $prefix
  • $sep
  • $key
  • $urlencode

Source code

function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {

	$ret = array();



	foreach ( (array) $data as $k => $v ) {

		if ( $urlencode)

			$k = urlencode($k);

		if ( is_int($k) && $prefix != null )

			$k = $prefix.$k;

		if ( !empty($key) )

			$k = $key . '%5B' . $k . '%5D';

		if ( $v === NULL )

			continue;

		elseif ( $v === FALSE )

			$v = '0';



		if ( is_array($v) || is_object($v) )

			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));

		elseif ( $urlencode )

			array_push($ret, $k.'='.urlencode($v));

		else

			array_push($ret, $k.'='.$v);

	}



	if ( NULL === $sep )

		$sep = ini_get('arg_separator.output');



	return implode($sep, $ret);

}

15437

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: