How do I add elements to an array only if they aren\'t in there already? I have the following:
$a=array(); // organize the array foreach($array as $k=>$v)
You should use the PHP function in_array (see http://php.net/manual/en/function.in-array.php).
in_array
if (!in_array($value, $array)) { $array[] = $value; }
This is what the documentation says about in_array:
Returns TRUE if needle is found in the array, FALSE otherwise.