Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

ProDevTips:
Sorting 2D-arrays in PHP - anectodes and reflections
Jan 07, 2008 @ 14:41:00

On the ProDevTips website today, there's a new article looking at the sorting of arrays, specifically of the two- and three-dimensional sort.

One of the many problems with PHP that detractors are eager to point out is the fact that the language has thousands of global functions. Without the awesome CHM version of the PHP manual - finding your way in this jungle would be a mess. Simply finding a function like array_multisort is not trivial. And even if you find it, understanding it completely is not trivial either!

Not quite finding what he needed in the array_multisort function built into PHP, the author opts to create his own custom sorting function that make sorting 2D arrays simpler.

tagged: sort 2d 3d array dimensional arraymultisort usort tutorial sort 2d 3d array dimensional arraymultisort usort tutorial

Link:

ProDevTips:
Sorting 2D-arrays in PHP - anectodes and reflections
Jan 07, 2008 @ 14:41:00

On the ProDevTips website today, there's a new article looking at the sorting of arrays, specifically of the two- and three-dimensional sort.

One of the many problems with PHP that detractors are eager to point out is the fact that the language has thousands of global functions. Without the awesome CHM version of the PHP manual - finding your way in this jungle would be a mess. Simply finding a function like array_multisort is not trivial. And even if you find it, understanding it completely is not trivial either!

Not quite finding what he needed in the array_multisort function built into PHP, the author opts to create his own custom sorting function that make sorting 2D arrays simpler.

tagged: sort 2d 3d array dimensional arraymultisort usort tutorial sort 2d 3d array dimensional arraymultisort usort tutorial

Link:

LivePipe Blog:
Complex Sorting with PHP
Jun 28, 2007 @ 12:11:21

On the LivePipe blog today, there's a quick new article demonstrating a sorting method that can be used for more than just simple datasources:

Most often when I need to sort complex data sets, I'm using some sort of SQL backend. Today I needed to do complex sorting of Reflection objects for some auto generating documentation I'm working on for the upcoming Picora release. [...] In the usort() examples, I had always been under the assumption that the return values had to be 0, 1 or -1. Today I learned that is not true at all, and you can come up with your own scoring system with any range, negative or positive.

He illustrates the point with a simple example showing the sorting of the documentation for Picora. In his protected function, scoreFromMethod, he defines the return array with several values instead of just the one.

tagged: complex sort usort example picora complex sort usort example picora

Link:

LivePipe Blog:
Complex Sorting with PHP
Jun 28, 2007 @ 12:11:21

On the LivePipe blog today, there's a quick new article demonstrating a sorting method that can be used for more than just simple datasources:

Most often when I need to sort complex data sets, I'm using some sort of SQL backend. Today I needed to do complex sorting of Reflection objects for some auto generating documentation I'm working on for the upcoming Picora release. [...] In the usort() examples, I had always been under the assumption that the return values had to be 0, 1 or -1. Today I learned that is not true at all, and you can come up with your own scoring system with any range, negative or positive.

He illustrates the point with a simple example showing the sorting of the documentation for Picora. In his protected function, scoreFromMethod, he defines the return array with several values instead of just the one.

tagged: complex sort usort example picora complex sort usort example picora

Link:


Trending Topics: