6 August 2019

The fastest string parsing is using existing functions, in this case you can use the strpos() which is used to find the occurrence of one string inside another one. When you need a stripos() for a case-insensitive version.

Source code viewer
  1. $a = 'A code is worth a thousand words';
  2.  
  3. if (strpos($a, 'thousand') !== false) {
  4. echo 'Contains the word thousand!';
  5. }
Programming Language: PHP