On Monday, 18 April 2011 at 21:52, Ashley Sheridan wrote:
On Mon, 2011-04-18 at 21:41 +0100, Stuart Dallas wrote:
> > On Monday, 18 April 2011 at 21:27, Ashley Sheridan wrote:
> > I'm trying to get the usort function working inside of a class, but am
> > > having some issues. Basically, the compare
On Mon, 2011-04-18 at 21:41 +0100, Stuart Dallas wrote:
> On Monday, 18 April 2011 at 21:27, Ashley Sheridan wrote:
> I'm trying to get the usort function working inside of a class, but am
> > having some issues. Basically, the compare function which is the second
> > parameter isn't recognised, bu
On Monday, 18 April 2011 at 21:27, Ashley Sheridan wrote:
I'm trying to get the usort function working inside of a class, but am
> having some issues. Basically, the compare function which is the second
> parameter isn't recognised, but I'm not really sure how to indicate
> exactly where it is.
>
On Thu, 2008-12-11 at 11:44 +1300, German Geek wrote:
> On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings <[EMAIL PROTECTED]>wrote:
>
> > On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
> > > On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote:
> > >
> > > > On 10 Dec 2008, at 04
On Thu, Dec 11, 2008 at 12:28 PM, <[EMAIL PROTECTED]> wrote:
>
> > Inefficiency for me is when it takes longer to code.
>
> How long can this take?
That's why i like PHP. It's very quick to do stuff in, even if arrays are
not always the ultimate data structure, they're easy to handle with all the
> Inefficiency for me is when it takes longer to code.
How long can this take?
Even if you go full-blown with an Interface and static methods that have to be
fleshed out in the implementations, you're still talking about an hour or so.
Quit complaining and start typing.
:-)
> PHP is
PHP is a scripting language.
Everytime the compiler has to parse the source.
You can not except true OOP performance.
OOP behavior is okay.
If performance is the main factor, an C extension will do that.
--
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu
--
PHP General Mailing
On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings <[EMAIL PROTECTED]>wrote:
> On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
> > On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote:
> >
> > > On 10 Dec 2008, at 04:15, German Geek wrote:
> > >
> > >> I need to sort an array of ob
You can use a (base) object Comparable with a method compareTo as the callback
function for http://php.net/usort
That gives you 99% of what you want, for the tiny price of having to pass in
the array('Comparable','compareTo') as the callback arg.
Given that one frequently calls usort and f
may be you can design a class.
interface ISortable{
public sort();
public compare($a,$b);
}
SortableList implements ISortable {
}
--
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/u
On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
> On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote:
>
> > On 10 Dec 2008, at 04:15, German Geek wrote:
> >
> >> I need to sort an array of objects. I found this ( at a url that didnt let
> >> me send this msg... ) and I would kn
On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote:
> On 10 Dec 2008, at 04:15, German Geek wrote:
>
>> I need to sort an array of objects. I found this ( at a url that didnt let
>> me send this msg... ) and I would know how to do it, but I believe there
>> might be a cleaner, more e
On 10 Dec 2008, at 04:15, German Geek wrote:
I need to sort an array of objects. I found this ( at a url that
didnt let
me send this msg... ) and I would know how to do it, but I believe
there
might be a cleaner, more elegant way to do it. In Java, you just
need to
implement the interface Co
It works thanks a lot!
--- On Fri, 5/9/08, Richard Heyes <[EMAIL PROTECTED]> wrote:
> From: Richard Heyes <[EMAIL PROTECTED]>
> Subject: Re: [PHP] usort inside a class
> To: [EMAIL PROTECTED]
> 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()
Working perfect, thanks :) I did RTFM but I did miss that :)
-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 24, 2006 3:46 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] usort within a class
On Thu, 2006-08-24 at 03:13 +0700
On Thu, 2006-08-24 at 03:13 +0700, Peter Lauri wrote:
> Hi,
>
> Is it possible to have the compare function in a class? I can not get it to
> work, this is pseudo code:
>
> class A {
>function getArray() {
> //dosomethingandgetanarray
> $array = blabla;
> usort($array, "$thi
$row[4];
$res[$i]['size'] = $row[5];
$res[$i]['weight'] = $result_array[$row[0]];
$i++;
}
usort($res, "cmp");
echo mysql_error();
$res['maxweight'] = $maxweight;
$res['results'] = $results;
return $res;
/**/
}
?>
That's not enough, we need the part that sits above an
On 28/02/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Can anyone comment and fix this error
>
> Warning: usort(): The argument should be an array in
> /home2/wwwabcde/public_html/search/searchfuncs.php on line 300
[...]
> usort($res, "cmp");
Put a print_r($res) a
Sorry, doesn't work either.
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
does not contain those that start with é:
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é
function usort_callback($a, $b) {
$a = str_replace(array('à', 'é'), array('a', 'e'), strtolow
Thanks!
What does var_dump do? (I didn't really understand the manual.)
"Miroslav Hudak (php/ml)" wrote:
> Pardon me for the strtolower line, i've just forgot there... it's 4:30AM
> here in Slovakia... :/
>
> correct listing follows...
>
> $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'a
Pardon me for the strtolower line, i've just forgot there... it's 4:30AM
here in Slovakia... :/
correct listing follows...
$authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert',
'alfred', 'amadeus', 'elen');
function usort_callback($a, $b) {
$a = str_replace(array('á', 'é'), array
this is slightly changed function of yours, written for better
readability...
$authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert',
'alfred', 'amadeus', 'elen');
function usort_callback($a, $b) {
$a = strtolower($a); $b = strtolower($b);
$a = str_replace(array('á', 'é'), arra
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é
It still sorts "é" and "e" separately, but without a parse error:
$first = array('à', 'é');
$second = array('a', 'e');
usort($authors, create_function('$a,$b','
John Taylor-Johnston wrote:
I think my problem lies in usort. I have a big honker of an array which I usort.
$ausenquiry = "e";
and
$ausenquiry = "e";
give a separate result.
I want to conjoin them. Possible? The same would be true for "a" and "à".
usort distinguishes between é and e. Any way aroun
Try using rsort()
Jay
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
No need to write your own function, it's already in PHP. :-)
What you're looking for it natsort(). It uses natural order string
comparison (which takes into account numbers instead of just using
characters like a regular search does).
There are also lots of other 'nat' functions, such as strnat
On Sat, 25 Oct 2003 04:03:12 +0300, you wrote:
>I don't know what the names are. I just know that there might be numbers. :)
>
>It still doesn't work. It gives very odd results with the $x_out variables.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.n
Curt Zirzow wrote:
* Thus wrote Shmuel ([EMAIL PROTECTED]):
file_1.ext
file_2.ext
file_3.ext
file_10.ext
file_40.ext
function mycmp($a, $b) {
if ($a == $b) {
return 0;
}
$a_n = preg_match("/\D+(\d+)\D+/", $a, $a_out);
$b_n = preg_match("/\D+(\d+)\D+/
* Thus wrote Shmuel ([EMAIL PROTECTED]):
> file_1.ext
> file_2.ext
> file_3.ext
> file_10.ext
> file_40.ext
>
> function mycmp($a, $b) {
> if ($a == $b) {
> return 0;
> }
> $a_n = preg_match("/\D+(\d+)\D+/", $a, $a_out);
> $b_n = preg_match("/\D+(\d+)\
Thank you.
I now have it working and it makes sense.
Jonathan
On Thursday, April 3, 2003, at 04:26 PM, Ernest E Vogelsinger wrote:
[snip]
The compare callback is expected to return anything < 0 if the first
value
is less than the second (should sort _be
At 23:53 03.04.2003, Jonathan Pitcher said:
[snip]
>This email is long I apologize for that. It is my code and then what
>it returns and what I am wanting it to return. I don't think I
>understand how USORT works or even if I am using the right function f
32 matches
Mail list logo