Ensuring a String Always Ends with a Given String
Learn how to ensure a string always ends with a given string with the help of examples.
We'll cover the following
The finish
helper method
It will ensure that the provided string (the $value
) always ends with exactly one occurrence of another string (the $cap
). This helper method is advantageous when constructing URIs or file paths. The cap can be any string of characters and does not have to be only a single character.
Get hands-on with 1200+ tech skills courses.