Re: [PHP] comparisons

2002-03-22 Thread Andrey Hristov


 if (ereg(john,$jeff) ) { }
 
ok
 or:
 
 if( strstr( $jeff, john) ) { }
 
ok
 or:
 
 if( strpos( $jeff, john) ) { }
error

if  (strpos($jeff, john) !== FALSE)

Best regards,
Andrey Hristov



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




RE: [PHP] comparisons

2002-03-22 Thread Rick Emery

Andrey, you are incorrect.

From the manual on strpos():
int strpos (string haystack, string needle [, int offset])
If needle is not found, returns FALSE. 

-Original Message-
From: Andrey Hristov [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 7:47 AM
To: Rick Emery
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] comparisons



 if (ereg(john,$jeff) ) { }
 
ok
 or:
 
 if( strstr( $jeff, john) ) { }
 
ok
 or:
 
 if( strpos( $jeff, john) ) { }
error

if  (strpos($jeff, john) !== FALSE)

Best regards,
Andrey Hristov


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




Re: [PHP] comparisons

2002-03-22 Thread Andrey Hristov

From the docs :
Note: It is easy to mistake the return values for character found at position 0 and 
character not found.  Here's how to detect
the difference:

// in PHP 4.0b3 and newer:
$pos = strpos($mystring, b);
if ($pos === false) { // note: three equal signs
// not found...
}

// in versions older than 4.0b3:
$pos = strpos($mystring, b);
if (!is_integer($pos)) {
// not found...
}

Andrey

- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: 'Andrey Hristov' [EMAIL PROTECTED]; Rick Emery [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, March 22, 2002 3:58 PM
Subject: RE: [PHP] comparisons


 Andrey, you are incorrect.

 From the manual on strpos():
 int strpos (string haystack, string needle [, int offset])
 If needle is not found, returns FALSE.

 -Original Message-
 From: Andrey Hristov [mailto:[EMAIL PROTECTED]]
 Sent: Friday, March 22, 2002 7:47 AM
 To: Rick Emery
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] comparisons



  if (ereg(john,$jeff) ) { }
 
 ok
  or:
 
  if( strstr( $jeff, john) ) { }
 
 ok
  or:
 
  if( strpos( $jeff, john) ) { }
 error

 if  (strpos($jeff, john) !== FALSE)

 Best regards,
 Andrey Hristov


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




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




RE: [PHP] comparisons

2002-03-22 Thread Rick Emery

ahhhinteresting.

thank you for the clarification

I stand humbled, head bowed...

rick

-Original Message-
From: Andrey Hristov [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 8:03 AM
To: Rick Emery
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] comparisons


From the docs :
Note: It is easy to mistake the return values for character found at
position 0 and character not found.  Here's how to detect
the difference:

// in PHP 4.0b3 and newer:
$pos = strpos($mystring, b);
if ($pos === false) { // note: three equal signs
// not found...
}

// in versions older than 4.0b3:
$pos = strpos($mystring, b);
if (!is_integer($pos)) {
// not found...
}

Andrey

- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: 'Andrey Hristov' [EMAIL PROTECTED]; Rick Emery
[EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, March 22, 2002 3:58 PM
Subject: RE: [PHP] comparisons


 Andrey, you are incorrect.

 From the manual on strpos():
 int strpos (string haystack, string needle [, int offset])
 If needle is not found, returns FALSE.

 -Original Message-
 From: Andrey Hristov [mailto:[EMAIL PROTECTED]]
 Sent: Friday, March 22, 2002 7:47 AM
 To: Rick Emery
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] comparisons



  if (ereg(john,$jeff) ) { }
 
 ok
  or:
 
  if( strstr( $jeff, john) ) { }
 
 ok
  or:
 
  if( strpos( $jeff, john) ) { }
 error

 if  (strpos($jeff, john) !== FALSE)

 Best regards,
 Andrey Hristov


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



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




RE: [PHP] comparisons

2001-02-12 Thread PHPBeginner.com

try this first:

if((strlen($pick1)==strlen(pick2))and($pick1==$pick2))
echo 'they are equal';
else
echo 'they aren\'t at least in length';

However, it seens to me as a very slicky style ...  whay not to make them
somehow different   let's say using an array, or having a letter instead
of 0 ...


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Curtis Maurand [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 12, 2001 3:48 AM
To: [EMAIL PROTECTED]
Subject: [PHP] comparisons


Hello,
  I'm having a rather strange problem.  I'm trying to compare two values.
"01" and "1".  The variables names that they are submitted under are pick1
and pick2.   i use the following code

$mypick1 = strval($pick1);
$mypick2 = strval($pick2);

I then perform the following comparison:

if ($mypick1 == $mypick2)
 {
   $error = 1;
   $errorstring[1] = "Your first pick and second pick are the same.";
 }

However, I get the error that they are equal.

If I call the comparison as foloows:

if(strval($mypick1) == strval($mypick2)
 {
   $error = 1;
   $errorstring[1] = "Your first pick and second pick are the same.";
 }

I still get the error.  Anyone have any ideas?  These two valuse mustbe
evaluated as different.

Thanks in advance
Curtis


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] comparisons

2001-02-12 Thread Christian Reiniger

On Monday 12 February 2001 10:41, PHPBeginner.com wrote:

   I'm having a rather strange problem.  I'm trying to compare two
 values. "01" and "1".  The variables names that they are submitted
 under are pick1 and pick2.   i use the following code

[...]

 I still get the error.  Anyone have any ideas?  These two valuse mustbe
 evaluated as different.

if (strcmp ($pick1, $pick2) == 0)
  echo "equal";
else
  echo "different";

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

Those who will not reason, are bigots,
those who cannot, are fools,
and those who dare not, are slaves.

- George Gordon Noel Byron (1788-1824), [Lord Byron]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] comparisons

2001-02-11 Thread Curtis Maurand

Hello,
  I'm having a rather strange problem.  I'm trying to compare two values.  "01" and 
"1".  The variables names that they are submitted under are pick1 and pick2.   i use 
the following code

$mypick1 = strval($pick1);
$mypick2 = strval($pick2);

I then perform the following comparison:

if ($mypick1 == $mypick2)
 {
   $error = 1;
   $errorstring[1] = "Your first pick and second pick are the same.";
 }

However, I get the error that they are equal.

If I call the comparison as foloows:

if(strval($mypick1) == strval($mypick2)
 {
   $error = 1;
   $errorstring[1] = "Your first pick and second pick are the same.";
 }

I still get the error.  Anyone have any ideas?  These two valuse mustbe evaluated as 
different.

Thanks in advance
Curtis



Re: [PHP] comparisons

2001-02-11 Thread Phil Driscoll

In spite of yor best efforts here, PHP converts the string values to numbers (because 
the strings look like numbers) before doing the comparison.

Force a string comparison by using strcmp and everything will work fine - remember 
that strcmp returns true if the strings are not equal and false if equal.

Cheers 

 Reply Header 
Subject:[PHP] comparisons
Author: "Curtis Maurand" [EMAIL PROTECTED]
Date:Sun, 11 Feb 2001 18:47:31 +

Hello,
  I'm having a rather strange problem.  I'm trying to compare two values.  "01" and 
"1".  The variables names that they are submitted under are pick1 and pick2.   i use 
the following code

$mypick1 = strval($pick1);
$mypick2 = strval($pick2);

I then perform the following comparison:

if ($mypick1 == $mypick2)
 {
   $error = 1;
   $errorstring[1] = "Your first pick and second pick are the same.";
 }

However, I get the error that they are equal.

If I call the comparison as foloows:

if(strval($mypick1) == strval($mypick2)
 {
   $error = 1;
   $errorstring[1] = "Your first pick and second pick are the same.";
 }

I still get the error.  Anyone have any ideas?  These two valuse mustbe evaluated as 
different.

Thanks in advance
Curtis




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] comparisons

2001-02-11 Thread Curtis Maurand

That was the solution.  It worked like a charm.

$cmpresult = strcmp($pick1,$pick2);
 if $cmpresult == 0)
  {
my code;
  }

Can I also write that like the following?

if (strcmp($pick1,$pick2) == 0)
 {
   perform some action;
 }

Will that work?

Curtis


- Original Message -
From: "Phil Driscoll" [EMAIL PROTECTED]
To: "Curtis Maurand" [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Sunday, February 11, 2001 2:34 PM
Subject: Re: [PHP] comparisons


 In spite of yor best efforts here, PHP converts the string values to
numbers (because the strings look like numbers) before doing the comparison.

 Force a string comparison by using strcmp and everything will work fine -
remember that strcmp returns true if the strings are not equal and false if
equal.

 Cheers

  Reply Header ________
 Subject: [PHP] comparisons
 Author: "Curtis Maurand" [EMAIL PROTECTED]
 Date: Sun, 11 Feb 2001 18:47:31 +

 Hello,
   I'm having a rather strange problem.  I'm trying to compare two values.
"01" and "1".  The variables names that they are submitted under are pick1
and pick2.   i use the following code

 $mypick1 = strval($pick1);
 $mypick2 = strval($pick2);

 I then perform the following comparison:

 if ($mypick1 == $mypick2)
  {
$error = 1;
$errorstring[1] = "Your first pick and second pick are the same.";
  }

 However, I get the error that they are equal.

 If I call the comparison as foloows:

 if(strval($mypick1) == strval($mypick2)
  {
$error = 1;
$errorstring[1] = "Your first pick and second pick are the same.";
  }

 I still get the error.  Anyone have any ideas?  These two valuse mustbe
evaluated as different.

 Thanks in advance
 Curtis





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re: [PHP] comparisons

2001-02-11 Thread Phil Driscoll

Can I also write that like the following?

if (strcmp($pick1,$pick2) == 0)
 {
   perform some action;
 }

that will work, but I prefer
Can I also write that like the following?

if (!strcmp($pick1,$pick2))
 {
   perform some action;
 }
Cheers

Phil


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re: [PHP] comparisons

2001-02-11 Thread Curtis Maurand



 that will work, but I prefer
 Can I also write that like the following?
 
 if (!strcmp($pick1,$pick2))
  {
perform some action;
  }

Thanks.  That works for me.  

Curtis


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]