rustyofco Posted November 17, 2006 Share Posted November 17, 2006 My array goes like this:[code]$array[1][a] = 8253EF$array[1][b] = joe$array[2][a] = 2016HG$array[2][b] = bob$array[3][a] = 5768NT$array[3][b] = adam[/code]I want to sort it so that the item in the [a] key goes ascending alphabetically (alphanumerically), but it stays with its associated name (the b key).So in the end, I want [code]$array[1][a] = 2016HG$array[1][b] = bob$array[2][a] = 5768NT$array[2][b] = adam$array[3][a] = 8253EF$array[3][b] = joe[/code]What function is this? Link to comment https://forums.phpfreaks.com/topic/27618-sorting-multidimentional-arrays/ Share on other sites More sharing options...
Barand Posted November 17, 2006 Share Posted November 17, 2006 In this instance[code]<?php$array[1]['a'] = '8253EF';$array[1]['b'] = 'joe';$array[2]['a'] = '2016HG';$array[2]['b'] = 'bob';$array[3]['a'] = '5768NT';$array[3]['b'] = 'adam';array_multisort($array) ;echo '<pre>', print_r($array, true), '</pre>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/27618-sorting-multidimentional-arrays/#findComment-126313 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.