if($i < sizeof($todayorders)) { // If next array element is different, parse the table if($todayorders[$i+1]->cat_id <> $t->cat_id) { echo " -- ok"; } // Next $i++; }