Source Code:
(back to article)
<?php // $text is a string variable $text = "Hello World!"; // Using the strpos() function to check if "World" exists in $text if (strpos($text, "World") !== false) { // If strpos() returns a value other than false, it means "World" is found in $text echo "Found 'World' in '$text'"; } else { // If strpos() returns false, it means "World" is not found in $text echo "Could not find 'World' in '$text'"; }
Result:
Report an issue