check if string begins with php code example
Example 1: Check if a String Starts With a Specified String in PHP
phpCopy<?php
$string = "Mr. Peter";
if(strncmp($string, "Mr.", 3) === 0){
echo "The string starts with the desired substring.";
}else
echo "The string does not start with the desired substring.";
?>
Example 2: Check if string starts with php
substr( $string_n, 0, 4 ) === "http"