How to use the str_contains function to check if a string contains a given substring, str_starts_with function to check if a string starts with a given substring, and str_ends_with function to check if a string ends with a given substring.
Author: BrainBell
Learn how to use strtr( ) function to translate characters and replace substrings in a given string.
Search all occurrences of a word or character and replace them with a replacement word or character.
Replace a portion of string by position
How to use substr_replace function to replace a string portion with another string by a specified position and length. You’ll also learn how to use array syntax over a string to access or modify an nth character by its index number.
Extract text before or after the match
How to retrieve the portion of text from a string with the help of strstr(), stristr(), strrchr(), and strpbrk() function.
In this tutorial, we’ll use the substr_count() function to determine how many times a substring occurs in a string.
Find positions of a substring in a string
How to find the position of the first or last occurrence of a substring in a string. You’ll also learn how to find the all positions of a substring in a string (or a multibyte string).
Use the substr() function to extract a portion of a string. Use mb_substr() function instead if you are dealing with a multibyte string.
How to remove leading and trailing whitespace from a string and how to replace line breaks in a string with <br> tags.
Padding Strings
Pad a string on the left, on the right, or on both the left and the right using str_pad() and printf() functions.