Problem:- Find the Second Largest Number in an Array Using PHP?, how to find highest and second highest number in an array without function, Find the second highest variable in array, Find Second largest element in an array
Solution – Find the Second Largest Number in an Array Using PHP
<?php $num = array(20, 520, 52, 755, 75, 15, 561, 656, 765); $max = $num[0]; $smax; for($i=1; $i<count($num); $i++){ if($num[$i]>$max){ $smax = $max; $max = $num[$i]; }else if($smax<$num[$i] && $smax < $max){ $smax = $num[$i]; } } echo $smax; ?>