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.
>
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.
I've gone over the usort() docs and read the user comments, and th
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
Hi Guys,
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 Comparable and provide a method called compa
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()
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: usor
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
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, "$this->myCompareFunction");
//Or maybe "A::myCompareFunction"
}
$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
No this doesnt solve error.
let me give you more details to understand problem with the said code.
go to this link, please.
http://www.abcdefg.us/search/search.php
in search enter,
Justice, you get response without an error.
Now enter law,
you get error, pasted below,
Warning: usort(): The a
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
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
below is part of the code which gives this error, the line highlighted
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','
Dunno the original question, but this obviously should be escaped...
So the correct code follows...
usort($authors, create_function('$a,$b','
$a = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $a);
$b = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $b);
return strc
Sorry. Still getting a parse error on line 40:
39> usort($authors, create_function('$a,$b','
40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
42> return strcasecmp($a,$b);'));
Can you have two arrays
I'm sorry, I used unescaped single quotes inside single quoted string,
this is right:
usort($authors, create_function('$a,$b','
$a = str_replace(array("é", "à"), array("e", "a"), $a);
$b = str_replace(array("é", "à"), array("e", "a"), $b);
return strcasecmp($a,$b);'));
Joh
I went with this, but am getting a parse error.
usort($authors, create_function('$a,$b','
$a = str_replace(array('é', 'à'), array('e', 'a'), $a);
$b = str_replace(array('é', 'à'), array('e', 'a'), $b);
return strcasecmp($a,$b);'));
Anyone see it? I've got headaches from sq
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
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 around this? I don't see any i
Try using rsort()
Jay
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hello,
I have an array like that:
$return[0]["photo"] = monuments_01.jpg
$return[1]["photo"] = monuments_00.jpg
$return[2]["photo"] = monuments_03.jpg
$return[3]["photo"] = monuments_02.jpg
$return[4]["photo"] = monuments_04.jpg
If I use the sort function:
sort($return) ;
I get
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+)\
Hi,
I'm trying sort an array. It has entries like this:
file_1.ext
file_2.ext
file_3.ext
file_10.ext
file_40.ext
and so on.
I want to sort them alphabetically first and then by the numbers.
If I sort them normally I get them like this:
file_1.ext
file_10.ext
file_2.ext
file_3.ext
file_40.ext
Wha
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
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 for
what I am looking for.
Thanks in advance for your help
Jonathan Pitcher
###
A quite anusual problem - and I can't figure it out..
My script, using the usort-function works properly
on my local php-environment (PHP 4.0.6) but not
on my server, running php 4.1.2!
I've read in a documentation, that php since 4.1.0
doesn't accept zero as return-value of the compare-function.
Hello,
Do you know the answer to this got'tcha? I want to call usort with a variable function
name. Basically, I want usort to sort any field I specify. Currently, I'm stuck
declaring a pile of functions and calling usort from if/elseif statements. :-(
Current:
function compname ($a, $b) {
Greets,
I am playing around with usort and an LDAP class. Basically, I want to sort
the results of an LDAP search based on a specific criterion.
class CLDAP {
var $m_Entries;
var $m_LinkIdentifier;
...
function Connect() {
...
}
function Bind() {
...
}
function FindEn
49 matches
Mail list logo