ZF-1480: add 3 new methods to Zend_Uri_Http
Description
method Zend_Uri_Http::getQueryAsArray() get the query params in an array
method Zend_Uri_Http::addQueryParams($params=array()) which add or replace params in the query string
method Zend_Uri_Http::removeQueryParams($params=array()) which remove params in the query string
/**
* Returns the query portion of the URL (after ?)
*
* @return array
*/
public function getQueryAsArray()
{
$queryParams = array();
if($queryString = $this->getQuery()){
$temp = explode('&', $queryString);
foreach($temp as $param){
list($key, $value) = explode('=', $param);
$queryParams[$key] = $value;
}
}
return $queryParams;;
}
/**
* Add or replace params in the query string for the current URI, and return the old query
*
* @param array $queryParams
* @return string Old query string
*/
public function addReplaceQuery($queryParams)
{
$queryParams = array_merge($this->getQueryAsArray(), $queryParams);
return $this->setQuery($queryParams);
}
/**
* Remove params in the query string for the current URI, and return the old query
*
* @param array $queryParams
* @return string Old query string
*/
public function addReplaceQuery($queryParams)
{
$queryParams = array_diff($this->getQueryAsArray(), $queryParams);
return $this->setQuery($queryParams);
}
Comments
Posted by Shahar Evron (shahar) on 2007-06-05T06:41:45.000+0000
This should be discussed for post 1.0 features
Posted by Bill Karwin (bkarwin) on 2007-06-07T11:27:13.000+0000
Assign to Shahar.
Posted by Stefan Gehrig (sgehrig) on 2009-11-19T07:20:36.000+0000
closed in trunk (r19041).
Added