abdfahim Posted May 8, 2010 Share Posted May 8, 2010 Hi, I have one array like this $a[0][0] = "aasd"; $a[0][1] = "3"; $a[0][2] = "dsad"; $a[1][0] = "eq"; $a[1][1] = "1"; $a[1][2] = "dsf"; $a[2][0] = "tre"; $a[2][1] = "2"; $a[2][2] = "ete"; etc. Now I want to sort the 1st index of the array based on value of $a[][1]. That means, in each $a[][1] item, I have a number, and I want to sort the 1st index of array based on that number (I dont wanna sort the sub-array). So, after sorting, the array should look like, $a[0][0] = "eq"; $a[0][1] = "1"; $a[0][2] = "dsf"; $a[1][0] = "tre"; $a[1][1] = "2"; $a[1][2] = "ete"; $a[2][0] = "aasd"; $a[2][1] = "3"; $a[2][2] = "dsad"; etc. Is there any easy way except manual loop and check? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/201101-sort-multi-dimensional-array/ Share on other sites More sharing options...
teamatomic Posted May 8, 2010 Share Posted May 8, 2010 array_multisort HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/201101-sort-multi-dimensional-array/#findComment-1055060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.