I have an array like this,
Output:
Array
(
[3] => stdClass Object
(
[id] => 11591
[title] => abc
)
[2] => stdClass Object
(
[id] => 11592
[title] => xyz
)
[0] => stdClass Object
(
[id] => 11589
[title] => abg
)
[1] => stdClass Object
(
[id] => 11590
[title] => asw
)
)
Codeigniter Code:
foreach($results as $rowData)
{
if($rowData->title=='xyz')
{
$eventperDayArray['0']=$rowData;
}
else if($rowData->title=='asw')
{
$eventperDayArray['1']=$rowData;
}
else if($rowData->title=='abc')
{
$eventperDayArray['2']=$rowData;
}
else if($rowData->title=='abg')
{
$eventperDayArray['3']=$rowData;
}
if($i==5)
{
print_r($eventperDayArray);
die();
break;
}
$i++;
}
i'm searching the data from array and want to sort it. Now when i print_r($eventperDayArray); it
I get output something like this now i want to sort it such that 0 index should come first and so on.
I have used sort and ksort but it did'nt work it prints 1.