我有一个这样的数组,
输出:
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
)
)
代码:
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++;
}
我正在从数组中搜索数据并希望对其进行排序。现在,当 我得到这样的输出时print_r($eventperDayArray);,
我想对它进行排序,以便 0 索引应该排在第一位,依此类推。我用过sort,ksort但它没有工作它打印1。
幕布斯6054654
德玛西亚99