Checking If a String Ends With a Specific Text in PHP


PHP 8 introduced str_ends_with() for this purpose.

Source Code

if (str_ends_with('Hello, World!', 'World!')) {
    echo "String ends with 'World!'.";
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments