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

Derick Rethans:
Natural Language Sorting with MongoDB 3.4
Dec 16, 2016 @ 09:28:33

Derick Rethans (of MongoDB) has posted an update to his site sharing the details about an improvement that comes with MongoDB 3.4 and is supported by the PHP driver: natural language sorting.

Arranging English words in order is simple—most of the time. You simply arrange them in alphabetical order. Sorting a set of German words, or French words with all of their accents, or Chinese with their different characters is a lot harder than it looks.

[...] Years ago I wrote about collation and MongoDB. There is an old issue in MongoDB's JIRA tracker, SERVER-1920, to implement collation so that sorting and indexing could work depending on the different sorting orders as described for each language (locale). Support for these collations have finally landed in MongoDB 3.4 and in this article we are going to have a look at how they work.

He starts off by explaining a bit about how Unicode collation works and PHP's support through the intl extension in the Collator class. He provides a code example using the class, showing the difference in sorting them first as English words then as Norwegian words. He moves into the MongoDB world and shows how the queries using this new collation support would be structured before moving back to PHP and using the MongoDB client to make the same requests. He also includes examples showing how to set the default locale, the "strength" (for the level of comparison), sorting and some interesting quirks with certain locales.

tagged: mongodb derickrethans natural language sorting tutorial driver

Link: https://derickrethans.nl/mongodb-collation-revised.html

Zend PHP Certification Blog:
PHP Sorting Functions
Dec 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.

tagged: sorting function array natural reverse key user

Link:

Elizabeth Naramore's Blog:
Growing Online Communities Naturally
Apr 20, 2009 @ 10:24:07

In this recent post to her blog Elizabeth Naramore looks at something some development (and really any type) of community struggles with - growing their number of active, engaged members.

From my experience, one key to a successful online community is the sort of magic that happens between community members that keeps it vibrant and growing. You can't force that kind of magic, and you can't clone it. It just happens.

She points out just a few of the resources you and your groups can use to help get others involved including wikis, mailing lists, IRC channels (I hear Freenode is nice) and twitter. She also gives specific examples of PHP-related community resources she's involved in like the PHPBuilder.com forums, her local PHP user group and the PHPWomen group.

What makes a community tick? [...] I'm no psychologist, but I can offer up a few words of advice for those struggling to grow their community or find that magic. Lay all your cards out on the table and see which ones gather momentum. [...] Let the group grow naturally and remember the complexity of the group dynamics is what dictates how the group will gel, not the leader.
tagged: member communicate usergroup grow natural community online

Link: