Answers for "php regex does not startswith"

PHP
2

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.";
?>
Posted by: Guest on April-23-2021
0

php regex strin start with

$string = "amora";
$result = preg_match("#^amor(.*)$#i", $string);
if($result == 0)
{
    echo "No match";
}
else
{
    echo "Match found.";
}
//out: Match found.
Posted by: Guest on September-10-2021

Browse Popular Code Answers by Language