Issues

ZF-1480: add 3 new methods to Zend_Uri_Http

Issue Type: Improvement Created: 2007-06-02T09:12:35.000+0000 Last Updated: 2009-11-19T07:20:36.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Laurent Melmoux (laurent melmoux) Assignee: Stefan Gehrig (sgehrig) Tags: - Zend_Uri

Related issues: Attachments:

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
<pre class="highlight"> 

/**
     * 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

  • Zend_Uri_Http::getQueryAsArray()
  • Zend_Uri_Http::addReplaceQueryParameters(array $queryParams)
  • Zend_Uri_Http::removeQueryParameters(array $queryParamKeys)

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts