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.

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

2007-10-01 Thread Kevin Murphy
Overly simplified version of my code. $site = http://www.wnc.edu;; $referer = $_SERVER[HTTP_REFERER]; echo $referer; // the output is correct at: http://www.wnc.edu/test/ if (strpos($referer,$site) === TRUE) { echo yes; } Why doesn't it echo out yes? I know I am doing something

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 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, 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 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

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,

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); //if

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) {

[PHP] strpos with array?

2005-05-10 Thread Merlin
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 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 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 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 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

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

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. why is !==

[PHP] strpos mystery

2004-07-28 Thread Jon Drukman
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. why is !== false not the same as === true ? -jsd- -- PHP General

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 if statement

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 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

[PHP] strpos

2004-01-21 Thread Martin Hjort Eriksen
Hello everybody I am currently working on an rtf to html converter, and for this i need a function that can find a specific control word in the file. Because of the sheer number control words in the rtf standard, I have to be shure that I have the control word, by examining the trailing

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, \\.$word,

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

[PHP] strpos() act funny when searching for ]]....

2003-11-21 Thread Scott Fletcher
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? Scott F. -- PHP General Mailing List (http://www.php.net/)

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 da'

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 to it? It

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 =

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,![CDATA[)+9);

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:

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 'gt;' ? 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

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

2003-11-21 Thread Scott Fletcher
Yea, it's a and not a gt;.. 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 sure

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 =

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 ![CDATA[]] tag...Like this

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 look

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

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.net/)

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 strpos() and

[PHP] StrPos/stristr

2003-03-04 Thread John Taylor-Johnston
http://www.php.net/manual/en/function.stristr.php http://www.php.net/manual/en/function.strpos.php Input from a textarea name=something I want to scan endless lines of $something. If the First Three characters of any line begin with au: (case insensitive) I want to filter out that line, and let

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

[PHP] strpos

2001-11-15 Thread jtjohnston
I suppose I'm doing this right? I want to know if the user entered \.jpeg or \.jpg. If he didn't, it should error. It errors anyways? What do I have to do add slashes in my input??? :o) // if((!strpos($yourimage, \.jpg)) || (!strpos($yourimage, \.jpeg))) \\ --- tried both!