I have a php array like this:-
array(3) {
[0]=>
string(4) "9:30"
[1]=>
string(5) "15:00"
[2]=>
string(5) "13:00"
}
After sorting this time i am getting wrong data. i am sorting it by array_multisort
function.
This is what i am getting after time is sorted
array(3) {
[0]=>
string(5) "03:00"
[1]=>
string(5) "01:00"
[2]=>
string(5) "09:30"
}
This is my code
first i am converting my time to unix time by using strtotime function then sorting like this:
while($row11 = mysqli_fetch_array($hourget))
{
$totlahourdat1[] = strtotime($row11['hours']);
$totlahourdat2[] = $row11['hours'];
}
echo "<pre>";
var_dump($totlahourdat2);
echo "</pre>";
//sort data
array_multisort($totlahourdat1, SORT_DESC);
//var_dump($totlahourdat);
foreach($totlahourdat1 as $time){
$totlahourdat[] = date("h:i",$time);
}
echo "<pre>";
var_dump($totlahourdat);
echo "</pre>";
if i print my $totlahourdat1
array then i get this:
array(3) {
[0]=>
int(1500535800)
[1]=>
int(1500555600)
[2]=>
int(1500548400)
}
My result should be like:
array(3) {
[0]=>
string(4) "9:30"
[1]=>
string(5) "13:00"
[2]=>
string(5) "15:00"
}
Any help will be highly appreciated.