Q:

Write a PHP script that checks whether a string contains another string

0

Write a PHP script that checks whether a string contains another string

All Answers

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

<?php
$pattern = '/[^\w]fox\s/';
if (preg_match($pattern, 'The quick brown fox jumps over the lazy dog'))
  {
  echo "'fox' is present..."."\n";
  }
  else
  echo "'fox' is not present..."."\n";
?>

Sample Output:

'fox' 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