Ngôn ngữ PHP - Kiểm tra một chuỗi có chứa một chuỗi khác

Viết một tập lệnh PHP để kiểm tra xem một chuỗi có chứa một chuỗi khác hay không.

Ví dụ:

PHP Regular Expression Exercise: Checks whether a string contains another string

Mã nguồn php:

<?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";
?>

Xem ví dụ

Lưu đồ thuật toán:

Flowchart: Checks whether a string contains another string.