Return to Snippet

Revision: 9755
at November 20, 2008 11:52 by section31


Initial Code
function array_numeric_to_assoc($arr) {
	$arr = array_values($arr);
	$new_arr = array();
	for ($i = 0, $count = count($arr); $i < $count; $i += 2) {
		$new_arr[$arr[$i]] = isset($arr[$i + 1]) ? $arr[$i + 1] : null;
	}
	return $new_arr;
}

Initial URL

                                

Initial Description
This requires a one dimensional array.

Initial Title
Numeric Array to Associative Array

Initial Tags

                                

Initial Language
PHP