Jeffery Fernandez wrote:
Jochem Maas wrote:

...


....

Yes the example sent by Kurt Yoder worked for me. I coudn't work out the errors with the class you sent me. I realised it was written for PHP5 in mind ?... or maybe I wasn't patient enough to spent time debugging it :-(


I did change it for php5 (to get rid of E_STRICT warnings IIR) - but the change was fairly cosmetic:

the class def starts like:


class MDASort {

    private $dataArray; //the array we want to sort.
    private $sortKeys;  //the order in which we want the array to be sorted.


if you change that to:


class MDASort {

    var $dataArray; //the array we want to sort.
    var $sortKeys;  //the order in which we want the array to be sorted.


then the class should work under php4 as advertised (adding an '&' as you do below in the callback definition wouldn't hurt either).

...


and within my class I am calling the following two lines:

   // Sort the array
   $this->mArraySortKey = 'score';
   usort($this->mSearchData, array(& $this, 'sort_array'));


cool, taking apart someone elses code and rewriting it one of the best ways
of learning/understanding IMHO. btw the '&' before $this is not strictly 
required,
but it should save you a few cycles :-)



cheers,
Jeffery Fernandez
http://melbourne.ug.php.net

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to