PHP Demo
PHP Code
Output
$search_term=$_POST["searchterm"]; $source_string = 'In this demo, I am using a user entered search term to check if string contains search term or not by using stripos!'; $posistion = stripos($source_string, $search_term); if( $search_term ){ echo "
"; 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 substring found at: $posistion"; } echo "
"; }
The markup
Enter a string: