String Contains


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

startsWith, endsWith, Contains


Copy this code and paste it in your HTML
  1. function str_startsWith($haystack, $needle) {
  2. return strpos($haystack, $needle) === 0;
  3. }
  4.  
  5. function str_endsWith($haystack, $needle){
  6. return strrpos($haystack, $needle) === strlen($haystack)-strlen($needle);
  7. }
  8.  
  9. function str_contains($haystack, $needle) {
  10. return strpos($haystack, $needle) !== false;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.