[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."
[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
[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
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
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
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
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);
//
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) {
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_
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_
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)
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?
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,
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
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 ==
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 *
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
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
>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
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
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
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()
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
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]]].]
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
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
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
[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
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);
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
* 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
[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
$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
33 matches
Mail list logo