Сер 022012
 

Вернуть массив без повторяющихся элементов без array_unique()

<?php

$row = array(‘1’, ‘1’, ‘1’, ‘2’, ‘2’, ‘3’, ‘3’, ‘4’, ‘4’, ‘5’, ‘5’);

function a_unique($row) {

$un = array();

foreach ($row as $k1=>$r) {
$accept = true;
foreach ($un as $k2=>$t) {
if ($r == $t) $accept = false;
}
if ($accept == true) $un[] = $r;
}

return $un;

}

$row = a_unique($row);

foreach ($row as $k=>$num) {
echo $num;
}

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)