i am trying to create a function that takes an array of numbers and, then, returns both the minimum and the maximum number from the given array as an associative array using arrays and for loops.
For example:
$sample = array( 135, 2.4, 2.67, 1.23, 332, 2, 1.02);
$output = get_max_and_min($sample);
var_dump($output);
//$output should be equal to array('max' => 332, 'min' => 1.02);*/
Here's my code so far:
$sample = array( 135, 2.4, 2.67, 1.23, 332, 2, 1.02);
function get_max_and_min($array){
for($i=0; $i>=$array; $i++){
echo $i;
}
}
$output = get_max_and_min($sample);
echo $output;
/* var_dump($output); */
Any idea? Thanks!