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
Avatarjohn asked 4 months 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:


$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);

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


i hope you can help me, thanks.

1 Answers
Best Answer
AvatarFernando answered 4 months ago
Your Answer

1 + 13 =

Popular Tags

WP Facebook Auto Publish Powered By :