Skip to content
Advertisement

php: the best way to check if string ends with an element from array?

JavaScript

What’s the best way to check if $str1 ends with some string from $arr1? The answer true/false is great, although knowing the number of $arr1 element as an answer (if true) would be great.

Example:

JavaScript

Is there any better/faster/special way than just comparing in for-statement all elements of $arr1 with the end of $str1?

Advertisement

Answer

Off the top of my head…..

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement