$final = array_intersect(array(4,5,6,7,8), array(1,2,3,4,5,6,7,8)); foreach($final as $f) { echo $f . '<br />'; }