Q:

Write a PHP script to check whether a string contains a specific string?

0

Write a PHP script to check whether a string contains a specific string?

Sample string : 'The quick brown fox jumps over the lazy dog.'
Check whether the said string contains the string 'jumps'

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$str1 = 'The quick brown fox jumps over the lazy dog.';
if (strpos($str1,'jumps') !== false) 
 {
    echo 'The specific word is present.';
 }
else
 {
    echo 'The specific word is not present.';
 }
?>

Sample Output:

The specific word is present.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now