API16:JURI/buildQuery
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Build a query from a array (reverse of the PHP parse_str()).
Syntax
buildQuery($params, $akey=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| $params | ||
| $akey | null |
Returns
string The resulting query string.
Defined in
libraries/joomla/environment/uri.php
Importing
jimport( 'joomla.environment.uri' );
Source Body
public function buildQuery($params, $akey = null) { if (!is_array($params) || count($params) == 0) { return false; } $out = array(); //reset in case we are looping if (!isset($akey) && !count($out)) { unset($out); $out = array(); } foreach ($params as $key => $val) { if (is_array($val)) { $out[] = JURI::buildQuery($val,$key); continue; } $thekey = (!$akey) ? $key : $akey.'['.$key.']'; $out[] = $thekey."=".urlencode($val); } return implode("&",$out); }
[Edit See Also] SeeAlso:JURI/buildQuery
Examples
<CodeExamplesForm />
