Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php check if string ends with

function startsWith( $haystack, $needle ) {
     $length = strlen( $needle );
     return substr( $haystack, 0, $length ) === $needle;
}
Comment

php check if string ends with

function endsWith( $haystack, $needle ) {
    $length = strlen( $needle );
    if( !$length ) {
        return true;
    }
    return substr( $haystack, -$length ) === $needle;
}
Comment

How To Check If A String Ends With Another String In PHP

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);
}
Comment

PHP str_ends_with — Checks if a string ends with a given substring

<?php
if (str_ends_with('abc', '')) {
    echo "All strings end with the empty string";
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: group where conditions in laravel 
Php :: on running php file showing code instead of view 
Php :: date time format php 
Php :: custom autoload without composer php psr4 
Php :: php multiple variables assign same value 
Php :: generate unique order id in php 
Php :: last_insert_id() php 
Php :: get filesize php 
Php :: remove last comma from string php foreach 
Php :: get curl httcode php 
Php :: php cookies 
Php :: trait php 
Php :: get data from 2 table in response laravel 
Php :: laravel response json status 500 
Php :: country code validation in laravel 
Php :: run codeigniter 4 with spark 
Php :: symlink.php laravel 
Php :: php bulk insert mysql 
Php :: fillable property to allow mass assignment 
Php :: php stop loading page 
Php :: php radians to degrees 
Php :: - in php 
Php :: laravel model 
Php :: localhost redirected you too many times. php 
Php :: html pagination php 
Php :: php get index of string 
Php :: ci4 throw new exception 
Php :: laravel validation required if 
Php :: execute function php 
Php :: strrev php 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =