I am using this code for comparing string values in a method, which work perfectly. But for some value it gives wrong value, for example below values:
Code:
$string1 = "65";
$string2 = "5-fold";
$result = strcasecmp($string1, $string2);
switch ($result) {
case -1: print "65 comes before 5-fold"; break;
case 0: print "65 and 5-fold are the same"; break;
case 1: print "65 comes after 5-fold"; break;
}
Output:
65 comes after 5-fold
I use this code for sorted array list, which sort them like ( 65 comes before 5-fold ). may be this output of because the " - " or something else i don't know. Do you have any idea about this.....
Below code Sort the multi-dimensional array:
foreach($index_terms as $c=>$key) {
$sort_id[] = $key['id'];
$sort_term[] = $key['term'];
$sort_freq[] = $key['freq'];
}
array_multisort($sort_term, SORT_ASC, $index_terms);
65should come after5-fold.