473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1964
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
3682
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
2708
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
2902
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
1839
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
2036
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
1774
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
1312
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
1481
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
1252
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...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.