Ryan R Posted June 6, 2011 Share Posted June 6, 2011 Hi All, Thanks for your immense help before. I have one question regarding the example shown in the book "PHP6 and MySQL5" I tried it according to what this book said. However, I saw this error message "Fatal error: Class 'Collator' not found in C:\xampp\htdocs\collation.php on line 22" I am attaching the web page here. Please see below: ------------------------------------------------------------------------------------------------------------------------------------- <?php header ('Content-Type: text/html; charset=UTF-8'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Collation in PHP</title> </head> <body style="font-size: 18pt;"> <?php # Script 14.3 - collation.php // Create an array of words: $words = array('chère', 'côté', 'chaise', 'château', 'chaînette', 'châle', 'Chère', 'côte', 'chemise'); // Sort using the default PHP function: echo '<h3>Using sort()</h3>'; sort($words); echo implode('<br />', $words); // Sort using the Collator: echo '<h3>Using Collator</h3>'; $c = new Collator('fr_FR'); $c->sort($words); echo implode('<br />', $words); ?> </body> </html> --------------------------------------------------------------------------------------------------------------------------------------------- Thank you in advance and look forward to hearing from you soon. Link to comment Share on other sites More sharing options...
Larry Posted June 6, 2011 Share Posted June 6, 2011 You're welcome. As for this question, what version of PHP are you using? It's pretty important information, which is why the guidelines specifically recommend that you include it. In fact, if you want fast answers, I would recommend reviewing the guidelines, because there are lots of good suggestions there. Link to comment Share on other sites More sharing options...
Ryan R Posted June 8, 2011 Author Share Posted June 8, 2011 I contacted my hosting company to see if they have PHP6. However, the latest one that they have is PHP5. Where can I get PHP6 then? Link to comment Share on other sites More sharing options...
Larry Posted June 8, 2011 Share Posted June 8, 2011 PHP 6 has gone away since the book was written. Depending upon what version of PHP 5 you're using, there is an alternative solution using the Collator class. Link to comment Share on other sites More sharing options...
Ryan R Posted June 9, 2011 Author Share Posted June 9, 2011 Can you show me how I can apply the alternative solution? Link to comment Share on other sites More sharing options...
Larry Posted June 9, 2011 Share Posted June 9, 2011 I can, certainly, based upon the documentation at the PHP manual (http://us3.php.net/collator). However, it's only useful if you're using PHP 5.3 or greater with version 3.6 of the ICU library or greater installed. Link to comment Share on other sites More sharing options...
HartleySan Posted June 10, 2011 Share Posted June 10, 2011 That Collator library is quite interesting. Never heard of it, and it deals with some very advanced sorting. The Japanese hiragana check might prove useful for a site of mine in the future. Thanks. Link to comment Share on other sites More sharing options...
Larry Posted June 10, 2011 Share Posted June 10, 2011 Yeah, many of the things that I talk about in the book as being planned for PHP 6 ended up in PHP 5.3, in places like the SPL (Standard PHP Library). I'm trying to figure out how to introduce the SPL in the fourth edition of this book. The third edition of my PHP Advanced book will probably cover it in detail. 1 Link to comment Share on other sites More sharing options...
bharat Posted October 25, 2012 Share Posted October 25, 2012 Dear Larry, (http://us3.php.net/collator). I have chack above link but I can not understand howto use, When I run following example It will display error (Fatal error: Class 'Collator' not found in:) <?php $coll = collator_create( 'en_US' ); $arr = array( 'at', 'às', 'as' ); var_export( $arr ); collator_sort( $coll, $arr ); var_export( $arr ); ?> So I am requesting to you kindly give me proper suggestion. I am using wamp. Its have following version : Apache Version :2.2.21 PHP Version :5.3.8 MySQL Version :5.5.16 Version 2.English Version Plz provide me some code so I can solve this problum as soon as possible. Link to comment Share on other sites More sharing options...
Recommended Posts