X

How to return more than One Value In Function PHP?

Program- How to return more than One Value In Function PHP?

Solution – return more than One Value In Function PHP

<?php
function multi_value(array $value){
 $min_value = min($value);
 $max_value = max($value);
 $diff_value = $max_value-$min_value;
 return array($min_value, $max_value, $diff_value);
}
$value = array(1, 20, 30, 5, 60, 81, 75, 4);
list($min_value, $max_value, $diff_value) = multi_value($value);
print "Min Value is- ".$min_value."<br> Max Value is- ".$max_value." <br> Diff is ".$diff_value ;
?>

Another Example

<?php
function time_parts($time){
 return explode(':', $time);
}
list($hour, $min, $seconds) = time_parts('12:34:15');
print $hour;
?>

इसे भी पढ़े – MC/Period जल्दी लाने के घरेलू उपाय