Printing minimum in each iteration print the value if output is not equal to current value ( to avoid the duplicates )
if ( $ output != $ next [ $ toincrement ] ) { $ output = $ next [ $ toincrement ] ; echo $ next [ $ toincrement ] . " " ; $ i ++ ; }