How do I split a string by .
delimiter in PHP? For example, if I have the string "a.b"
, how do I get "a"
?
explode
does the job:
$parts = explode('.', $string);
You can also directly fetch parts of the result into variables:
list($part1, $part2) = explode('.', $string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With