472,791 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

help with strpos

say i have the following php script:

<?
if (!is_int(strpos("a","aaa")))
// if (strpos("a","aaa") === false)
print "no match";
else print "match";
?>

when i run it, i am told there is no match, when there actually is.
it doesn't matter which if statement i use (the uncommented out one,
or the commented out one) - i get the same thing. further, if i
change "aaa" to "xxx", it doesn't, all of a sudden, say "match"
(indicating that i would just need to swap the statements) - it
*still* says no match.

so, any ideas as to what's wrong with my code? any help would be
appreciated - thanks :)
Jul 17 '05 #1
2 1938
In article <a0**************************@posting.google.com >,
te*******@yahoo.com (yawnmoth) wrote:
say i have the following php script:

<?
if (!is_int(strpos("a","aaa")))
// if (strpos("a","aaa") === false)
print "no match";
else print "match";
?>

when i run it, i am told there is no match, when there actually is.


It should be:

strpos('aaa','a')

int strpos ( string haystack, string needle [, int offset])

<http://nl.php.net/strpos>

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2
Jan Pieter Kunst <de*****@cauce.org> wrote in message news:<de***************************@news1.news.xs4 all.nl>...
<snip>

It should be:

strpos('aaa','a')

int strpos ( string haystack, string needle [, int offset])

<http://nl.php.net/strpos>

JP


i can't believe i did that, heh. ah well - thanks :)
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various...
0
by: Baby Blue | last post by:
I have 2 code like below to grab a news website for my site. However, when I click some links (such as : http://wwww.vnexpress.net/xxx/xxxx ) inside the site which I want to grab, it has some...
3
by: Baby Blue | last post by:
I have 2 codes below to grap data from another site. I use them to get the data from one News site. However, when I click on some link inside (such as :...
2
by: ralphNOSPAM | last post by:
I'm trying to use strpos to find these xml tags so I can pull out the text data; but the bracket chars won't let the function work. Is there another way to do this? $php_XML_tag =...
3
by: julian_m | last post by:
file AddHTML.htm: ---------------------------- This line is <b>ok</b><br> This line is <b>ok</b><br> This line is <b>ok</b><br> <?PHP echo "This one has code prohibited "; ?> This line is...
2
by: drec | last post by:
I am trying to right an if statment using strpos to determine if the string exists in the variable, however I seem to be getting the wrong effect. Here is my script. <?php $dn = "ABC-DEF"; ...
13
by: cendrizzi | last post by:
I have no idea where to get help on RE stuff. Since it's for a PHP app I thought I would ask here to see if there was some RE pros. Basically I'm doing some template stuff and I wanted to use a...
2
by: helraizer1 | last post by:
Hi folks, I have a file for my chatbox called data.line, which the posts are in the layout CHATBOXTEXT 7 username=helraizer 1202416953
1
by: Michael Sharman | last post by:
Not quite sure what's happening here, the docs for strpos() say: "Returns the position as an integer. If needle is not found, strpos() will return boolean FALSE." Looks fine, I can simply...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.