PHP Version
5+
$str = 'Hello, World!';
$substring = 'world'; // Case-insensitive search

$pos = stripos($str, $substring);

if ($pos !== false) {
    echo "Found at position: $pos";
} else {
    echo 'Not found.';
}

// Output: Found at position: 7

/*
 * Note:
 * String indexes in PHP start at 0.
 * The index of the first character is 0, and the second character is 1.
 */
stripos(string $haystack, string $needle, int $offset = 0): int|false
$haystack = 'Hello, World!';

var_dump(stripos($haystack, '')); // bool(false)
var_dump(strpos($haystack, '')); // Warning: strpos(): Empty needle in
$newstring = 'abcdef ghijk';
$pos = stripos($newstring, 'a');

var_dump($pos); // int(0)
$str = 'Hello, World!';
$substring = 'Hello';

$pos = stripos($str, $substring);

var_dump($pos); // int(0)

if ($pos === false) {
    echo "The string 'Hello' was not found.";
} else {
    echo "The string 'Hello' is included in the text.";
}

// Output: The string 'Hello' is included in the text.
$user_input = $_GET['search_query'];
$content = 'This is a sample text for searching.';

if (stripos($content, $user_input) !== false) {
    echo 'The search term was found.';
} else {
    echo 'The search term was not found.';
}
$string = 'The school bell rings, time to gather!';
$search_term = 'Bell';

if (stripos($string, $search_term) !== false) {
    echo 'The search term was found.';
} else {
    echo 'The search term was not found.';
}

// Output: The search term was found.
$string = 'Hello, world!';
$prefix = 'hello';

if (stripos($string, $prefix) === 0) {
    echo "The string starts with '$prefix'.";
} else {
    echo "The string does not start with '$prefix'.";
}

// Output: The string starts with 'hello'.