PHP Demo
PHP Code
Output
$search_term=$_REQUEST["term"]; if( $search_term ){ $chkstring = 'Following is a strpos demo with jQuery $.ajax method to check whether source string contains the search term or not, without reloading the webpage'; $termpos = strpos($chkstring, $search_term); if ($termpos === false) { echo "The search term '$search_term' is not found!"; } else { echo "The search term '$search_term' found at: $termpos position! "; } }
The Markup and jQuery code
A demo of strpos with $.ajax
Enter a string:
Result: