Ajax/php/yii/URI.php
function _uri_to_assoc($n=3, $default=array(), $which='segment') {
		if ($which == 'segment') {
			$total_segments='total_segments';
			$segment_array='segment_array';
		} else {
			$total_segments='total_rsegments';
			$segment_array='rsegment_array';
		}

		if (!is_numeric($n)) {
			return $default;
		}

		if (isset($this->keyval[$n])) {
			return $this->keyval[$n];
		}

		if ($this->$total_segments() < $n) {
			if (count($default) == 0) {
				return array ();
			}

			$retval=array ();
			foreach ( $default as $val ) {
				$retval[$val]=FALSE;
			}
			return $retval;
		}

		$segments=array_slice($this->$segment_array(), ($n - 1));

		$i=0;
		$lastval='';
		$retval=array ();
		foreach ( $segments as $seg ) {
			if ($i % 2) {
				$retval[$lastval]=$seg;
			} else {
				$retval[$seg]=FALSE;
				$lastval=$seg;
			}

			$i++;
		}

		if (count($default) > 0) {
			foreach ( $default as $val ) {
				if (!array_key_exists($val, $retval)) {
					$retval[$val]=FALSE;
				}
			}
		}

		// Cache the array for reuse
		$this->keyval[$n]=$retval;
		return $retval;
	}
function _uri_to_assoc($n=3, $default=array(), $which='segment') {
		if ($which == 'segment') {
			$total_segments='total_segments';
			$segment_array='segment_array';
		} else {
			$total_segments='total_rsegments';
			$segment_array='rsegment_array';
		}

		if (!is_numeric($n)) {
			return $default;
		}

		if (isset($this->keyval[$n])) {
			return $this->keyval[$n];
		}

		if ($this->$total_segments() < $n) {
			if (count($default) == 0) {
				return array ();
			}

			$retval=array ();
			foreach ( $default as $val ) {
				$retval[$val]=FALSE;
			}
			return $retval;
		}

		$segments=array_slice($this->$segment_array(), ($n - 1));

		$i=0;
		$lastval='';
		$retval=array ();
		foreach ( $segments as $seg ) {
			if ($i % 2) {
				$retval[$lastval]=$seg;
			} else {
				$retval[$seg]=FALSE;
				$lastval=$seg;
			}

			$i++;
		}

		if (count($default) > 0) {
			foreach ( $default as $val ) {
				if (!array_key_exists($val, $retval)) {
					$retval[$val]=FALSE;
				}
			}
		}

		// Cache the array for reuse
		$this->keyval[$n]=$retval;
		return $retval;
	}
function _uri_to_assoc ( $ n = 3 , $ default = array ( ) , $ which = 'segment' ) { if ( $ which == 'segment' ) { $ total_segments = 'total_segments' ; $ segment_array = 'segment_array' ; } else { $ total_segments = 'total_rsegments' ; $ segment_array = 'rsegment_array' ; } if ( ! is_numeric ( $ n ) ) { return $ default ; } if ( isset ( $ this -> keyval [ $ n ] ) ) { return $ this -> keyval [ $ n ] ; } if ( $ this -> $ total_segments ( ) < $ n ) { if ( count ( $ default ) == 0 ) { return array ( ) ; } $ retval = array ( ) ; foreach ( $ default as $ val ) { $ retval [ $ val ] = FALSE ; } return $ retval ; } $ segments = array_slice ( $ this -> $ segment_array ( ) , ( $ n - 1 ) ) ; $ i = 0 ; $ lastval = '' ; $ retval = array ( ) ; foreach ( $ segments as $ seg ) { if ( $ i % 2 ) { $ retval [ $ lastval ] = $ seg ; } else { $ retval [ $ seg ] = FALSE ; $ lastval = $ seg ; } $ i ++ ; } if ( count ( $ default ) > 0 ) { foreach ( $ default as $ val ) { if ( ! array_key_exists ( $ val , $ retval ) ) { $ retval [ $ val ] = FALSE ; } } } // Cache the array for reuse $ this -> keyval [ $ n ] = $ retval ; return $ retval ; }
Generate a key value pair from the URI string or Re-routed URI string

@access private
@param integer the starting segment number
@param array an array of default values
@param string which array we should use
@return array
Generate a key value pair from the URI string or Re - routed URI string