Check whether string ends with a given string


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function string_ends_with($string, $ending)
  2. {
  3. $len = strlen($ending);
  4. $string_end = substr($string, strlen($string) - $len);
  5.  
  6. return $string_end == $ending;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.