<?php
function selectSort(&$myArray){
$temp = 0;
for($i = 0;$i < count($myArray) - 1;$i++){
$minArr = $myArray($i);
$minIndex = $i;
for($j = $i + 1;$j < count($myArray);$j++){
if($minArr > $myArray[$j]){
$minArr = $myArray[$j];
$minIndex = $j;
}
}
$temp = $myArray[$i];
$myArray[$i] = $myArray[$minIndex];
$myArray[$minIndex] = $temp;
}
}
$arr = array(1,3,2,7,5,8);
selectSort($arr);
print_r($arr);
?>
function selectSort(&$myArray){
$temp = 0;
for($i = 0;$i < count($myArray) - 1;$i++){
$minArr = $myArray($i);
$minIndex = $i;
for($j = $i + 1;$j < count($myArray);$j++){
if($minArr > $myArray[$j]){
$minArr = $myArray[$j];
$minIndex = $j;
}
}
$temp = $myArray[$i];
$myArray[$i] = $myArray[$minIndex];
$myArray[$minIndex] = $temp;
}
}
$arr = array(1,3,2,7,5,8);
selectSort($arr);
print_r($arr);
?>