You can extract a portion of a string by using thesubstr()function.
Specify the start index and the number of characters you want to return.
Syntax:
substr(string $string, int $start, int $length = ?);
$string: The input string.
$start: The starting position to slice. A positive number counts from the beginning (0-indexed). A negative number counts from the end of the string.
$length(optional): The length of the substring to extract. If not provided, it extracts from $start to the end of the string. A negative value of$length will exclude characters from the end.
We use cookies and similar technologies to enhance your browsing experience, serve personalized content and advertisements, and analyze our traffic.
By clicking "Accept All", you consent to our use of cookies and the processing of your personal data for these purposes.
You can manage your preferences or learn more in our
Privacy Policy and
Cookie Policy.