How to use preg_match() function in PHP

preg_match() function returns the value of the matches string or text.

preg_match() function contains the 2 parameters, one is a pattern and the second is a string.

<?php
$string = "Visit W3Schools";
$pattern = "/w3schools/i";
// $pattern is search the text "w3schools" in the $string variable and return the number of times found value.
echo preg_match($pattern, $str); 

// result 1 
// w3schools found 1 time in the $string variable
?>

How to use preg_match() function in PHP2expoundsofttechsolution
How to get the current URL of Laravel in controller and view?