To sort an array of string without using php function?
try this...
$str = array(“Z”,”c”,”A”,”C”,”E”,”B”,”M”,”N”);
$array_length = sizeof($str);
for($x = 0; $x < $array_length; $x++) {
for($y = 0; $y < $array_length; $y++) {
if(strcasecmp($str[$x],$str[$y])<0) {
$hold = $str[$x];
$str[$x] = $str[$y];
$str[$y] = $hold;
}
}
}
echo "<pre>”;
print_r($str);
echo “</pre>”;
1 comment:
ya it's working
Post a Comment