PHP Demo
PHP Code
Output
$source_string = 'This is a strpos Tuotrial which is used to search strings. It tells whether a given string contains a search string or not!'; $search_term = 'strpos'; $posistion = strpos($source_string, $search_term); if ($posistion === false) { echo "The source string does not contain the: '$search_term'!"; } else { echo "The string contains the search term: '$search_term'! "; echo " The given substr found at: $posistion"; }
The string contains the search term: 'strpos'! The given substr found at: 10