In this this tutorial learn How to Check if a string contains a substring in php using a strpos() method - programming technology world
TUTORIAL
OUTPUT DEMO
function str_contains(string $string, string $substr): bool
{
return strpos($string, $substr) !== false;
}
TUTORIAL
<?php /** * Check if a string contains a substring * * @param string $string * @param string $substr * @return bool */ function str_contains(string $string, string $substr): bool { return strpos($string, $substr) !== false; } var_dump( str_contains("This is test!", "test!"));
bool(true)
No comments:
Post a Comment