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

Zend PHP Certification Blog:
PHP Sorting Functions
December 21, 2011 @ 11:39:06

On the "Zend PHP Certification" blog (study notes), there's sort and natsort).

In all the countless hours I've spent with php, I've maybe used three or four of these sorting functions. I really had no idea that there is a total of eleven functions used for sorting arrays. Anyway, I'm betting that it may be useful to have these memorized before I take the Zend PHP Certification Exam so here is a brief overview of each one.

He talks about the various flags that can be used in the sorting (for regular, numeric, string and locale-based string handling) and the parameters to call for normal sorting, "natural" sorting, reverse key sorting and others. You can find specifics on these array sorting methods in the PHP manual.

0 comments voice your opinion now!
sorting function array natural reverse key user


Zend Developer Zone:
Paging and Sorting Data with Zend Framework, Doctrine and PEAR (part 1)
December 11, 2009 @ 09:43:29

On the Zend Developer Zone there's the first part of a series looking at pagination and sorting of data with the combination of the Zend Framework, Doctrine and PEAR.

When building database-backed applications, one of the important problems for a developer or user interface engineer involves making large data sets more manageable by, and therefore more useful to, application users. [...] Back in the good old days, adding pagination to a PHP application was mostly a manual task, involving offset calculations and custom query generation. In recent years, the task has become significantly simpler, mostly due to the presence of ready-made pagination components in most common frameworks.

His tutorial uses the Zend Framework, Doctrine and the Pager, MDB2 and Structures_Datagrid PEAR packages. He starts with a basic select and format kind of example to show a few lines per page. To improve it (for larger data sets) he shows how to use the Zend_Paginator to only grab the rows needed for the page. Finally, he adds in code to allow for column sorting, making it easy to reorganize the results how you'd like.

1 comment voice your opinion now!
zendframework pagination sorting doctrine pear tutorial


Bjarte Karlsen's Blog:
Sorting with uasort
October 30, 2006 @ 13:25:00

Bjarte Karlsen has a handy tip posted to his blog today - one array function to keep in mind when doing more than just the basic sorting - uasort.

Problem: You have an array of objects or a multidimentional arrays where the key of the first array has some meaning. It could be a id or something else. You want to sort the array and maintain the key=>value association.

Some may then proceed to loop the array and sort it in a loop, however there is a easier method.

He reminds us that the fucntion allows you to take in the array and, based on a user-defined function, sort the results, keeping the association between the keys and values.

0 comments voice your opinion now!
sorting uasort user defined function maintian assoication sorting uasort user defined function maintian assoication


DevShed:
Collections and Sorting Continued
April 05, 2006 @ 07:13:17

Previously from DevShed, they started a series on collections and sorting in PHP. Today, they've posted part two of the series that builds on that and looks at sorting algorithm examples.

This article will examine the primary sorting algorithms with code examples, and some empirical data regarding how they perform in relation to one another, as well as the size of the data set in question.

We will also create a function to fill up our collection with random data in order to test the sort algorithms with a sufficiently large data set. The sort algorithms listed above are the ones that every computer science student learns in college and are the primary sort algorithms found in real-world applications.

The sorting styles they cover include: bubble sort, heap sort, merge sort, quick sort, and shell sort. For each, they provide the code, making it a simple matter of cut and paste to make it work in your script. There's not a whole lot of documentation going along with the code in this article, but the sorting code is simple enough to understand without it.

0 comments voice your opinion now!
collections sorting bubble heap merge quick selection shell collections sorting bubble heap merge quick selection shell


DevShed:
Collections and Sorting
March 29, 2006 @ 07:58:03

There are features in every language that developers love to have - in PHP, there are some impressive string and array handling functions that some developers would like to carry over. Unfortunately, there are also some bits of functionality that haven't quite made it to PHP yet - namely collections. In other languages, such as Java or C#, these handy containers let you hold objects for use later. PHP lacks this kind of functionality inherently, but this new DevShed article might just have a way around it.

A collection is an object whose primary function is to store a number of like objects. An object called CarCollection may contain any number of Car objects. Collections can traditionally be accessed in the same manner as arrays, which means CarCollection[n] represents a particular Car object. This is true in C#, Java, and more - but not PHP, unfortunately. Since PHP has only recently begun to develop a package of built in objects (the SPL, Standard PHP Library), the ability to support collections in the accepted behavioral sense is very limited.

Their mission is to work with a datatype that PHP does have to simulate this kind of collection handling - arrays. They walk you through the creation of a foundation class, one that simply allows you to get and fetch from the array. Extending that makes it possible to create a customized method for sorting personal data (name).

0 comments voice your opinion now!
collections sorting array non-native objects collections sorting array non-native objects



Community Events





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


package api framework install community language zendserver release introduction symfony tips interview bugfix opinion podcast laravel deployment unittest library series

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