PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > usort inside a class
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
usort inside a class

Réponse
 
LinkBack Outils de la discussion
Vieux 09/05/2008, 21h38   #1
It Maq
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut usort inside a class

Hi,

i'm trying to build a class that sorts a multidimensional array.
I'm using the php function "usort".

I declared the comparision function as a method of my class but i'm unable to give it as argument to the function usort.

this "usort($this->arr, $this->cmpi)" gaves the following error: usort() [function.usort]: Invalid comparison function

i tried to do "usort($this->arr, 'cmpi')" but it does not work either.

Thanks


__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i...Dypao8Wcj9tAcJ

  Réponse avec citation
Vieux 09/05/2008, 21h47   #2
Richard Heyes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] usort inside a class

> i'm trying to build a class that sorts a multidimensional array.
> I'm using the php function "usort".
>
> I declared the comparision function as a method of my class but i'm unable to give it as argument to the function usort.
>
> this "usort($this->arr, $this->cmpi)" gaves the following error: usort() [function.usort]: Invalid comparison function
>
> i tried to do "usort($this->arr, 'cmpi')" but it does not work either.


If it's anything like other functions, try this:

usort($this->arr, array($this, 'cmpi'));

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
  Réponse avec citation
Vieux 09/05/2008, 21h54   #3
It flance
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] usort inside a class

It works thanks a lot!


--- On Fri, 5/9/08, Richard Heyes <richardh@phpguru.org> wrote:

> From: Richard Heyes <richardh@phpguru.org>
> Subject: Re: [php] usort inside a class
> To: itmaqurfe@yahoo.com
> Cc: php-general@lists.php.net
> Date: Friday, May 9, 2008, 8:47 PM
> > i'm trying to build a class that sorts a

> multidimensional array.
> > I'm using the php function "usort".
> >
> > I declared the comparision function as a method of my

> class but i'm unable to give it as argument to the
> function usort.
> >
> > this "usort($this->arr, $this->cmpi)"

> gaves the following error: usort() [function.usort]:
> Invalid comparison function
> >
> > i tried to do "usort($this->arr,

> 'cmpi')" but it does not work either.
>
> If it's anything like other functions, try this:
>
> usort($this->arr, array($this, 'cmpi'));
>
> --
> Richard Heyes
>
> +----------------------------------------+
> | Access SSH with a Windows mapped drive |
> | http://www.phpguru.org/sftpdrive |
> +----------------------------------------+



__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10085 seconds with 11 queries