Discuss Basic array sort. First numbers, then characters in the PHP Development forum on Dev Shed. Basic array sort. First numbers, then characters PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Time spent in forums: 3 Weeks 3 Days 8 h 35 m 43 sec
Reputation Power: 275
Originally Posted by paulh1983
nice but surely you could use implode so that you dont have to do foreach, plus extra code to remove , at the end
implode() isn't something I've seen much (and I didn't see it listed in the examples for natsort() ), so, thats why I didn't use it. But, that would've been the proper way to go about my example for sure.
I appreciate all the advice given to me when I "screw up".
Time spent in forums: 2 Months 3 Weeks 5 Days 6 h 19 m 38 sec
Reputation Power: 6300
Implode wouldn't be listed in any manual pages for sorting, as it's usually used for output and has nothing to do with sorting. It is, however, the way you get around the "trailing comma" problem. Any time you have a list, use an array and the built-in array-specific functions to manage it (unless there's a good reason not to).