function startsWith( $haystack, $needle ) {
$length = strlen( $needle );
return substr( $haystack, 0, $length ) === $needle;
}
function endsWith( $haystack, $needle ) {
$length = strlen( $needle );
if( !$length ) {
return true;
}
return substr( $haystack, -$length ) === $needle;
}
function endsWith($haystack,$needle,$case=true) {
//If its case specific
if($case){
return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
<?php
if (str_ends_with('abc', '')) {
echo "All strings end with the empty string";
}
?>
Code Example |
---|
Php :: Create progress bar with Laravel |
Php :: woocommerce_recently_viewed |
Php :: php object example |
Php :: laravel casts pivot table |
Php :: use htaccess to redirect in cpanel laravel |
Php :: php loop through obect |
Php :: php convert path from server url to link |
Php :: php insert in array |
Php :: get HTML select value to PHP |
Php :: remove php |
Php :: laravel zoom integration |
Php :: pass the product name to form field cf7 woocommerce |
Php :: laravel route group |
Php :: php strftime year 2 digits |
Php :: get current month laravel |
Php :: php array sort |
Php :: havingraw in laravel |
Php :: laravel route regex except |
Php :: laravel toastr option |
Php :: php print |
Php :: laravel get query result as array |
Php :: laravel execute command arguments |
Php :: laravel best practices |
Php :: laravel repository design pattern |
Php :: install laravel scout |
Php :: yii2 oauth2 |
Php :: laravel 8 jwt api authentication |
Php :: cakephp |
Php :: connect php to db |
Php :: php read excel file |