How do I go about splitting a string by delimiter in PHP? For example, if I have the string “a.b”, how do I get “a”?
Jason from Maryland
How do I go about splitting a string by delimiter in PHP? For example, if I have the string “a.b”, how do I get “a”?
Jason from Maryland
Comments are closed.
Hello Jason
You need to use a PHP built-in function called explode. For example
$parts = explode('.', $string);
You can also directly fetch parts of the result into variables:
list($part1, $part2) = explode('.', $string);