Return to Snippet

Revision: 47602
at June 11, 2011 04:15 by anagaiyahoocom


Updated Code
/**
	* Will turn key=value string into associated array
	*
	* @param string $str key/value string to convert to array
        * @param string $delim 
	* @return array
	*/
	
	function explode_to_assoc_array($str,$delim)
	{
		$result = array();
		
		foreach (explode('&', $str) as $couple) {
			list ($key, $val) = explode('=', $couple);
			$result[$key] = $val;
		}
		
		return $result;	
	}

Revision: 47601
at June 11, 2011 02:46 by anagaiyahoocom


Initial Code
/**
	* Will turn key=value string into associated array
	*
	* @param string $str key/value string to convert to array
	* @return array
	*/
	
	function explode_to_assoc_array($str)
	{
		$result = array();
		
		foreach (explode('&', $str) as $couple) {
			list ($key, $val) = explode('=', $couple);
			$result[$key] = $val;
		}
		
		return $result;	
	}

Initial URL


Initial Description


Initial Title
Convert key/value string into associated array

Initial Tags
php

Initial Language
PHP