PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
theclay7
Forum Commoner
Posts: 50 Joined: Wed Feb 19, 2003 3:17 am
Post
by theclay7 » Wed May 14, 2003 3:56 am
if I want to compare two strings...for example
$compare_1 = "
http://www.codingforums.com/error.php?abc=123 ";
$compare_2 = "
http://www.codingforums.com/index.php ";
$compare = "error.php";
how do I get sub string from $compare_1 or $compare_2 to see if the URL has "error.php" (i.e. $compare)
if substr(($compare_1 has error.php) == $compare)
echo "matched";
how can I find if $compare_1 or $compare_2 consist of "error.php"
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed May 14, 2003 4:00 am
Crashin
Forum Contributor
Posts: 223 Joined: Mon May 06, 2002 3:42 pm
Location: Colorado
Post
by Crashin » Wed May 14, 2003 12:23 pm
You might look into:
Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.
From the same page referenced by volka.
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Wed May 14, 2003 1:37 pm
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu May 15, 2003 12:50 am
the first ( is just at the wrong position, the amount is correct
and yes, strpos() is probably more suitable.