As it appears standard PHP method array_unique is not suitable for multi-dimensional arrays. Too bad PHP guys…is that really that hard to add  ? Here is something I had to come up with.

public static function array_unique($array)
{
	array_walk($array,
		create_function('&$value,$key', '$value = json_encode($value);')
	);
	$array = array_unique($array);
	array_walk($array,
		create_function('&$value,$key', '$value = json_decode($value, true);')
	);
	return $array;
}

Dima Svirid

Software architect, JAVA, Spring, Hibernate, AngularJs, Backbone, MongoDB, Oracle. CTO and Co-Founder of Homeadnet.com

More Posts

Follow Me:

Tagged with: