Solved

PHP - Is $string1 contained in $string2 ?

Posted on 2012-03-22
3
494 Views
Last Modified: 2012-03-22
Hello,

I want to see if this exact string   href='r/  is contained in $mtopics
If not, then run 2 lines of code.

But, it always runs it, even if the string is present.
Can you help?

<?PHP
if(stristr($mtopics, "href='r/") === FALSE) {
$mtopics=str_replace("href='","href='$pre",$mtopics);
$reltopics=str_replace("href='","href='$pre",$reltopics);
}
?>

Thanks, Greg
0
Comment
Question by:gregsschipper
3 Comments
 
LVL 4

Accepted Solution

by:
petr_hlucin earned 500 total points
ID: 37754503
Use the following:
<?PHP
if(stristr($mtopics, 'href=\'r/') === FALSE) {
$mtopics=str_replace("href='","href='$pre",$mtopics);
$reltopics=str_replace("href='","href='$pre",$reltopics);
}
?>

Open in new window

0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 37754630
Please post the test data, thanks.
0
 

Author Closing Comment

by:gregsschipper
ID: 37754838
The BEST! Many Thanks, Greg - www.adventdigital.net
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, As I have seen there a lot of requests regarding monitoring and reporting for exchange 2007 / 2010 / 2013 I have decided to post some thoughts together and link to articles that have helped me. Of course a lot of information you can get…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question