Use array_diff() to filter the array:
<?php header('Content-Type: text/plain'); $buffer = array(null, 0, 1, 2, 3, 0, null, 1); $filtered = array_diff($buffer, array(null, 0)); $max = max($filtered); $min = min($filtered); var_dump($max, $min); ?>
Shows:
int(3) int(1)
Blitz
source share