RE: [PHP] strpos error (I'm missing something obvious)

2007-10-02 Thread Jay Blanchard
[snip] > !== FALSE is not good either, it is not a valid test > > strpos returns the numeric position of the first occurrence of needle in > the haystack string. Except when needle doesn't occur in string, in which case "If needle is not found, strpos() will return boolean FALSE."

Re: [PHP] strpos error (I'm missing something obvious)

2007-10-01 Thread Tom Swiss
[EMAIL PROTECTED] ("Jay Blanchard") writes: > !== FALSE is not good either, it is not a valid test > > strpos returns the numeric position of the first occurrence of needle in > the haystack string. Except when needle doesn't occur in string, in which case "If needle is not found, s

RE: [PHP] strpos error (I'm missing something obvious)

2007-10-01 Thread Jay Blanchard
[snip] I fixed this by changing === TRUE to !== FALSE, so I think I am good to go now. But would still like to know why TRUE doesn't work. Thanks. [/snip] !== FALSE is not good either, it is not a valid test strpos returns the numeric position of the first occurrence of needle in the haystack s

Re: [PHP] strpos error (I'm missing something obvious)

2007-10-01 Thread Carlton Whitehead
Kevin, I think I addressed that in my last message, if a bit indirectly. strpos will never return a boolean true. It will only ever return either the integer where the needle is found in the haystack, or false if said needle is not found in said haystack. Check the Return Values section at

Re: [PHP] strpos error (I'm missing something obvious)

2007-10-01 Thread Kevin Murphy
I fixed this by changing === TRUE to !== FALSE, so I think I am good to go now. But would still like to know why TRUE doesn't work. Thanks. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada College www.wnc.edu 775-445-3326 P.S. Please note that my e-mail and website

Re: [PHP] strpos error (I'm missing something obvious)

2007-10-01 Thread Carlton Whitehead
Kevin, Try this instead: $site = "http://www.wnc.edu";; $referer = $_SERVER["HTTP_REFERER"]; echo $referer;// the output is correct at: http://www.wnc.edu/test/ if (is_int(strpos($referer, $site))) { echo "yes"; } Why did I make this change? strpos returns an integer representing the

Re: [PHP] strpos with array?

2005-05-13 Thread Marek Kilimajer
Burhan Khalid wrote: Merlin wrote: Burhan Khalid wrote: Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); //

Re: [PHP] strpos with array?

2005-05-12 Thread Burhan Khalid
Merlin wrote: Burhan Khalid wrote: Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); //if ($pos !== false) {

Re: [PHP] strpos with array?

2005-05-10 Thread Merlin
Burhan Khalid wrote: Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); //if ($pos !== false) { if (in_

Re: [PHP] strpos with array?

2005-05-10 Thread Merlin
Burhan Khalid wrote: Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); //if ($pos !== false) { if (in_

Re: [PHP] strpos with array?

2005-05-10 Thread Burhan Khalid
Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); //if ($pos !== false) { if (in_array($term,$replace)

RE: [PHP] strpos with array?

2005-05-10 Thread Shaw, Chris - Accenture
Hello, Have you tried using array_keys or array_search for finding an occurrence in an array? HTH. Chris. -Original Message- From: Merlin [mailto:[EMAIL PROTECTED] Sent: 10 May 2005 11:11 To: php-general@lists.php.net Subject: [PHP] strpos with array?

Re: [PHP] strpos with array?

2005-05-10 Thread Marek Kilimajer
Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); if ($pos !== false) { $term = str_replace($replace,

RE: [PHP] strpos mystery

2004-07-29 Thread Ford, Mike [LSS]
On 29 July 2004 01:50, Jon Drukman wrote: > with this code fragment: > > > $string='/mobile/phone.html'; > if (strpos($string,'/mobile/')!==false) { print "one: yes\n"; } > if (strpos($string,'/mobile/')===true) { print "two: yes\n"; } > > > > > > only the first if statement prints anything

Re: [PHP] strpos mystery

2004-07-28 Thread Jason Barnett
Heck, even I got it wrong ;) True check below should always fail... Jason Barnett wrote: Because === and !== check the type as well. Of you set $string = 'blah' you'll still get the same result. If you were using != and == both would print. strpos() returns an int, so comparing it to false with ==

Re: [PHP] strpos mystery

2004-07-28 Thread Jason Barnett
Because === and !== check the type as well. Of you set $string = 'blah' you'll still get the same result. If you were using != and == both would print. strpos() returns an int, so comparing it to false with === is always false. The same would be true for true. That's half right. strpos actually *

Re: [PHP] strpos mystery

2004-07-28 Thread Justin Patrin
On Wed, 28 Jul 2004 17:50:01 -0700, Jon Drukman <[EMAIL PROTECTED]> wrote: > with this code fragment: > > > $string='/mobile/phone.html'; > if (strpos($string,'/mobile/')!==false) { print "one: yes\n"; } > if (strpos($string,'/mobile/')===true) { print "two: yes\n"; } > > ?> > > only the first

Re: [PHP] strpos

2004-01-21 Thread Martin Hjort Eriksen
Thank You very much. and I think I will go to bed now /Martin Mike Migurski wrote: When I use the function bellow, and there is no occournce of the control word, strpos shoul return false, but instead i returns 1, which is not the intention. Does anybody here have an idea about what I a

Re: [PHP] strpos

2004-01-21 Thread Mike Migurski
>When I use the function bellow, and there is no occournce of the control >word, strpos shoul return false, but instead i returns 1, which is not >the intention. Does anybody here have an idea about what I am doing >wring??? You're adding the one: >$position = strpos($this->fileContent, "\\".$wor

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
Yea! :-) Don't we all hate it? :-) "Mark Charette" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Fri, 21 Nov 2003, Scott Fletcher wrote: > > > Well, I seem to have problem understanding the word, 'offset' to the > > strpos() function because it is a bad choice of word > > str

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Mark Charette
On Fri, 21 Nov 2003, Scott Fletcher wrote: > Well, I seem to have problem understanding the word, 'offset' to the > strpos() function because it is a bad choice of word strpos() and the word "offset" used with it is probably older than you ... :) -- PHP General Mailing List (http://www.php.ne

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
With a moment of studying to your comment, I am beginning to see why I am having the problem. I add the 9 in the first two lines of code, so I didn't realize that I would have encounter the problem if I didn't add the 9. Well, I seem to have problem understanding the word, 'offset' to the strpos()

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Kelly Hallman
On Fri, 21 Nov 2003, Scott Fletcher wrote: > Ah! Found the problem... It is probably a bug with strpos() because it > seem to get stuck in there and couldn't get out of it somehow. The > workaround the problem I did was just easily increment the $HTML_End by 1 > and that fixed the problem. It lo

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
You can find more info about this on other branches, I found hte workaround to this problem. So, what am I expecting from strpos() is to find a starting point and ending point to the XML data and HTML data that are within the "" tag...Like this [XML[CDATA[XML..[CDATA...[HTML]]].]

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
Ah! Found the problem... It is probably a bug with strpos() because it seem to get stuck in there and couldn't get out of it somehow. The workaround the problem I did was just easily increment the $HTML_End by 1 and that fixed the problem. It look like this... --snip-- $XML_Start = (strpo

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
Yea, it's a ">" and not a ">".. It is pure XML tags Found the problem now, so no problem now. See other branch of this posting of a workaround to the problem I did... Thanks, Scott "Sophie Mattoug" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Just a stupid idea : are you

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Sophie Mattoug
Just a stupid idea : are you sure you have '>' in your text and not '>' ? Scott Fletcher wrote: I thought about that also, so I took your suggestion and tried it. Still doens't work... I tried those... "\]]>"; "\]\]>"; Scott F. "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL P

RE: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Jay Blanchard
[snip] I thought about that also, so I took your suggestion and tried it. Still doens't work... I tried those... "\]]>"; "\]\]>"; [/snip] I tried Curt's solution...no problem. What are you expecting from strpos()? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://w

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
Um, it seem to work. That's weird. Should have check for the string length first, so I wasn't looking at the same problem. So, I did further debugging and I'm going to post the script here. Still don't know what is the problem here... --snip-- $XML_Start = (strpos($res_str,"",$HTML_Start);

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Scott Fletcher
I thought about that also, so I took your suggestion and tried it. Still doens't work... I tried those... "\]]>"; "\]\]>"; Scott F. "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] strpos() is acting a little bit funny. When I do this... --snip-- $a = strpos

Re: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Curt Zirzow
* Thus wrote Scott Fletcher ([EMAIL PROTECTED]): > strpos() is acting a little bit funny. When I do this... > > --snip-- > $a = strpos($data,"]]>"); > --snip-- > > Problem is there are "]]>" characters in the $data string and it just > doesn't see it. Anyone know why and what is the workaround

RE: [PHP] strpos() act funny when searching for "]]>"....

2003-11-21 Thread Jay Blanchard
[snip] strpos() is acting a little bit funny. When I do this... --snip-- $a = strpos($data,"]]>"); --snip-- Problem is there are "]]>" characters in the $data string and it just doesn't see it. Anyone know why and what is the workaround to it? [/snip] Does it need to be escaped? *shootin' from

Re: [PHP] StrPos/stristr

2003-03-04 Thread Marek Kilimajer
$lines=explode("\n",$something); foreach($lines as $line) { if(eregi('^au: (.*)$',$line,$m)) { $au=$m[1]; // you may want to break here } } John Taylor-Johnston wrote: http://www.php.net/manual/en/function.stristr.php http://www.php.net/manual/en/function.strpos.php Input from