Loading, please wait...

A to Z Full Forms and Acronyms

How to check a case insensitive substring exists within the given string using a regular expression pattern in PHP | PHP program

Jun 24, 2021 PHP, 515 Views
How to check a case insensitive substring exists within the given string using a regular expression pattern in PHP | PHP program

How to check a case insensitive substring exists within the given string using a regular expression pattern in PHP | PHP program

We will perform regular expression pattern matching using the preg_match() function, here we checked a case insensitive substring exists in the specified string or not.

<?php


$str = "www.tutorialslink.com";
$pattern = "/tutorialslink/i";

$res = preg_match($pattern, $str);

if ($res == 1)
{
    printf("Substring found successfully");
}
else
{
    printf("Substring did not find in the string");
}

?>
A to Z Full Forms and Acronyms