我有一个多维数组,结构如下:
teamMembers[teamMembers][0][Name];
teamMembers[teamMembers][0][Email];
teamMembers[teamMembers][1][Name];
teamMembers[teamMembers][1][Email];
等
问题是有时数据是这样的:
teamMembers[teamMembers][0][Name];
teamMembers[teamMembers][0][Email];
teamMembers[teamMembers][3][Name];
teamMembers[teamMembers][3][Email];
teamMembers[teamMembers][4][Name];
teamMembers[teamMembers][4][Email];
teamMembers[teamMembers][7][Name];
teamMembers[teamMembers][7][Email];
有什么方法可以使用随机数组,所以上面的数组看起来像这样......
teamMembers[teamMembers][0][Name];
teamMembers[teamMembers][0][Email];
teamMembers[teamMembers][1][Name];
teamMembers[teamMembers][1][Email];
teamMembers[teamMembers][2][Name];
teamMembers[teamMembers][2][Email];
teamMembers[teamMembers][3][Name];
teamMembers[teamMembers][3][Email];
我猜不是,但如果可能的话,它肯定会帮助我! :(
答案 0 :(得分:2)
$teamMembers['teamMembers'] = array_values($teamMembers['teamMembers']);
答案 1 :(得分:0)
ksort($teamMembers['teamMembers']);