Check string is a substring of another string.

PHOTO EMBED

Mon May 22 2023 11:13:29 GMT+0000 (Coordinated Universal Time)

Saved by @stefcha22 #php

<?php

function isSubstring($string, $substring) 
{
    return strpos($string, $substring) !== false;
}

// Usage example:
$mainString = "Hello, World!";
$substring = "World";
if (isSubstring($mainString, $substring)) {
    echo "The substring '$substring' is found in the main string.";
} else {
    echo "The substring '$substring' is not found in the main string.";
}
content_copyCOPY