Skip to content

Commit

Permalink
fixed createPathInfo to work with arrays of infinite depth
Browse files Browse the repository at this point in the history
  • Loading branch information
poppitypop committed Dec 23, 2009
1 parent e187eba commit 56a737f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions framework/web/CUrlManager.php
Expand Up @@ -317,21 +317,20 @@ public static function parsePathInfo($pathInfo)
* @param array list of GET parameters
* @param string the separator between name and value
* @param string the separator between name-value pairs
* @param string only meant to used recursively. The key to the path.
* @return string the created path info
* @since 1.0.3
*/
public function createPathInfo($params,$equal,$ampersand)
public function createPathInfo($params,$equal,$ampersand, $key='')
{
$pairs=array();
foreach($params as $key=>$value)
{
if(is_array($value))
{
foreach($value as $k=>$v)
$pairs[]=urlencode($key).'['.urlencode($k).']'.$equal.urlencode($v);
}
$pairs = array();
foreach($params as $k => $v) {
if (!empty($key)) $k = $key.'['.urlencode($k).']';

if (is_array($v) || is_object($v))
array_push($pairs, $this->createPathInfo($v,$equal,$ampersand, $k));
else
$pairs[]=urlencode($key).$equal.urlencode($value);
array_push($pairs,$k.$equal.urlencode($v));
}
return implode($ampersand,$pairs);
}
Expand Down

0 comments on commit 56a737f

Please sign in to comment.