note 75480 deleted from function.array-combine by bjori

From: Date: Thu, 21 Feb 2008 20:27:22 +0000
Subject: note 75480 deleted from function.array-combine by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-136371@lists.php.net to get a copy of this message
Note Submitter: toth dot janas at gmail dot com ---- Under this note i send yesterday a function that in array show once the dupicated elements. Sorry, the function is wrong. I corrected the error and i write a new function is working right. /tested/. The test array is: $test = array( 0 => 1, 1 => 2, 2 => 1, 3 => 3, 4 => 4, 5 => 2, 6 => 5, 7 => 4 ); the function: function array_no_duplicate($array_tmb){ $temp = array(); foreach ($array_tmb as $value){ $if_one = 0; foreach ($temp as $new_value) { if($new_value == $value) $if_one = 1; } if($if_one == 0) array_push($temp, $value); } return $temp; } example: var_dump(array_no_duplicate($test)); this output will show array without duplicated elements. Good work!

« previous php.notes (#136371) next »