You can use list for this:
list($first) = explode(".", "foo.bar"); echo $first;
This also works if you need a second (or third, etc.) element:
list($_, $second) = explode(".", "foo.bar"); echo $second;
But it can become quite awkward.
alexn source share