Find the mid element of the array in php
How to find the mid element of the array in php
$arr = array('5','7','4','5','7','6','5','7','1','6','7','9','5','7','4');
// Find the array size
$total_size_of_array = count($arr);
$mid = $total_size_of_array / 2 ;
if(gettype($mid) == 'array'){
$midd = round($mid);
}else{
$mid = $mid ;
}
print_r ($arr[$mid]);
Result is : 7
look here as simple
ReplyDelete