<?php $test = array( 30.04, 0.00, 30.04, 0.00, 47.00, 17.03, 5.02, 25.08, 2.06, 32.06, 37.00, 7.07, ); $output = array(); foreach ($test as $key => $value) { // To make sure this will only be executed every second item if ($key % 2 !== 0) { continue; } $next = ''; if (!isset($test[$key+1])) { break; } else { $next = $test[$key+1]; } $output[$key] = $value . ' is ' . ($value < $next ? "lower" : ($value > $next ? 'higher' : 'equal')) . ' than ' . $next; } echo '<pre>'; print_r($output);
You have javascript disabled. You will not be able to edit any code.