Try to search your question here, if you can't find : Ask Any Question Now ?

Print array without being repeated PHP

HomeCategory: stackoverflowPrint array without being repeated PHP
john asked 4 days ago

how are you?

I am trying to print in php an array with data not repeated, i do not have any idea of how to achieve that thing, this is my code:

<?php

$ar = array(1,2,2,4,5);

function array_dup($ar){
   return array_unique(array_diff_assoc($ar,array_unique($ar)));
}

$dupes = array_dup($ar);
print_r(array_dup($ar));

foreach($ar as $y=>$y_value){
    if($y_value !== $dupes) {
        echo $y_value;
    }
}

?>

i hope you can help me, thanks.

1 Answers
Best Answer
Fernando answered 4 days ago
Your Answer

12 + 17 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com