note 75480 added to function.array-combine

From: Date: Fri, 01 Jun 2007 09:21:57 +0000
Subject: note 75480 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-127097@lists.php.net to get a copy of this message
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! ---- Server IP: 195.70.37.52 Probable Submitter: 86.101.78.147 ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- https://master.php.net/note/edit/75480 Del: integrated -- https://master.php.net/note/delete/75480/integrated Del: useless -- https://master.php.net/note/delete/75480/useless Del: bad code -- https://master.php.net/note/delete/75480/bad+code Del: spam -- https://master.php.net/note/delete/75480/spam Del: non-english -- https://master.php.net/note/delete/75480/non-english Del: in docs -- https://master.php.net/note/delete/75480/in+docs Del: other reasons-- https://master.php.net/note/delete/75480 Reject -- https://master.php.net/note/reject/75480 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127097) next »