PHP Splitting a string
explode and strstr are simpler methods to get substrings by separators.
A string containing several parts of text that are separated by a common character can be split into parts with the explode function.
The method also supports a limit parameter that can be used as follow:
If the limit parameter is zero, then this is treated as 1.
If limit is set and positive, the returned array will contain a maximum of limit elements with the last element
containing the rest of string.
If the limit parameter is negative, all components except the last -limit are returned.
['apple', 'pear', 'grapefruit']
explode can be combined with list to parse a string into variables in one line:
However, make sure that the result of explode contains enough elements, or an undefined index warning would be triggered.
strstr strips away or only returns the substring before the first occurrence of the given needle.