array_diff():-

The array_diff() function compares the values of two (or more) arrays, and returns the differences.

This function compares the values of two (or more) arrays, and return an array that contains the entries from array1 that are not present in array2 or array3, etc.

array_map():-

The array_map() function sends each value of an array to a user-made function, and returns an array with new values, given by the user-made function.

min():-

The min() function returns the lowest value in an array, or the lowest value of several specified values.

 code:-

<?php
function minvalue(Array $values) 
{
return min(array_diff(array_map('intval', $values), array(0)));
}
print_r(minvalue(array(-3,4,6,12,-300,-1,7))."\n");
?>

output:-
 -300

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post