You can use this for your question.(https://forums.digitalpoint.com/threads/how-to-print-only-repeated-number.2732259/) <?php $arr = array('1', '2', '1', '3', '4', '2', '7', '5', '6', '7', '1', '8', '9'); $tempArr = array(); foreach($arr as $eachElement) { if(!in_array($eachElement, $tempArr)) { echo $eachElement."<br/>"; $tempArr[] = $eachElement; } } ?>