News Feed
Sections




News Archive
feed this:

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

Brian Swan's Blog:
Sorting Azure Table Entities by Timestamp with PHP
April 27, 2011 @ 10:48:17

Brian Swan has a quick new post to his blog for the PHP + Azure users out there on how to easily sort table entities by a timestamp through the Azure SDK for PHP. The timestamp is a property on the parent storage table class, so you don't need to create it in your entity, it's already there.

The problem boils down to sorting an array of objects by a timestamp property, so the information here is nothing that hasn't been done before. However, after spending some time looking for a way to use a filter in the Windows Azure SDK for PHP API, I didn't find one, so I'm hoping this post might save others some time. In the end, my solution simply uses the PHP array_multisort function.

Sample code is included - a basic class extending Microsoft_WindowsAzure_Storage_TableEntity, a fetch for the entity set of the contacts and using a custom "objSort" method that sorts based on the returned timestamp values from the object set.

0 comments voice your opinion now!
azure sort table timestamp arraymultisort tutorial


ProDevTips:
Sorting 2D-arrays in PHP - anectodes and reflections
January 07, 2008 @ 08: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.

0 comments voice your opinion now!
sort 2d 3d array dimensional arraymultisort usort tutorial sort 2d 3d array dimensional arraymultisort usort tutorial


Felix Geisendorfer's Blog:
Sorting Challenge
October 26, 2007 @ 08:42:00

Felix Geisendorfer has a quick little sorting example posted today showing on way to sort a multi-dimensional array.

Quick challenge, lets say you have an array and you want to iterate through your products by [the key of each subarray in $products] Product.ordering ASC. Whats the fastest way to do this?

His solution involves using an array_flip call on the extracted information (using Set::extract), ordering it with ksort and pushing the values back into the $product array in the right order.

Check out the comments for more examples including ones that make use of array_multisort.

0 comments voice your opinion now!
sort challenge arraymultisort arrayflip foreach array sort challenge arraymultisort arrayflip foreach array


Ben Ramsey's Blog:
Flickr Namespace and array_multisort() Issues
December 18, 2006 @ 11:33:00

Ben Ramsey has posted a (quick) new items over on his blog that looks at solving two problems he was having with his blog - the now non-functional Flickr feed and a sorting problem with array_multisort.

I recently upgraded a few things around here (in particular, an upgrade to PHP 5.2), and I noticed two issues that occurred after the upgrade. [...] I easily solved both of these issues.

The correction to the Flickr feed involved changing the namespace information for his request (adding a trailing slash) because the SimpleXML functionality got a bit more particular about the format.

The problem with array_multisort involved adding in a parameter that was implied in previous PHP versions, SORT_STRING, to get his code correctly working.

2 comments voice your opinion now!
flickr namespace simplexml arraymultisort feed blogroll flickr namespace simplexml arraymultisort feed blogroll



Community Events





Don't see your event here?
Let us know!


community laravel testing threedevsandamaybe symfony2 opinion unittest configure developer podcast release introduction language install series experience interview list code framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework