php - how to sort this multi-dimensional array -


i trying change output on shopping cart software. believe have found array coming , need sort it. sort() didn't work. used print_r see array, , more dimensions small brain can handle. how sort full currency name?

array ( [0] => array ( [id] => usd [text] => dollar ) [1] => array ( [id] => eur [text] => euro ) [2] => array ( [id] => gbp [text] => united kingdom pound ) [3] => array ( [id] => cad [text] => canadian dollar ) [4] => array ( [id] => aud [text] => australian dollar ) [5] => array ( [id] => chf [text] => swiss franc ) [6] => array ( [id] => czk [text] => czech koruna ) [7] => array ( [id] => dkk [text] => danish krone ) [8] => array ( [id] => hkd [text] => hong kong dollar ) [9] => array ( [id] => huf [text] => hungarian forint ) [10] => array ( [id] => jpy [text] => japanese yen ) [11] => array ( [id] => nzd [text] => new zealand dollar ) [12] => array ( [id] => nok [text] => norwegian kroner ) [13] => array ( [id] => pln [text] => polish zloty ) [14] => array ( [id] => sgd [text] => singapore dollar ) [15] => array ( [id] => sek [text] => swedish krona ) [16] => array ( [id] => ils [text] => israeli new shekel ) [17] => array ( [id] => mxn [text] => mexican peso ) [18] => array ( [id] => twd [text] => taiwan dollar ) [19] => array ( [id] => php [text] => philippine peso ) [20] => array ( [id] => thb [text] => thai baht ) ) 

as interstellar_coder said, use usort, right!

usort($array,create_function('$a,$b','return strnatcasecmp($a["text"],$b["text"]);')); 

or, php 5.3 onwards:

usort($array,function($a,$b) {return strnatcasecmp($a['text'],$b['text']);}); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - EclipseLink JPA Object is not a known entity type -

java - Need to add SOAP security token -