arrays - How to use explode and get first element in one line in PHP? -
$ first dot = explosion (".", $ String) [0]; This is what I am trying to do, except that this syntax gives error if there is a workaround for a liner, please let me know if this is not possible , Please explain.
It was implemented in PHP 5.4, so if you are using an older version, Will have to do in another way.
An easy way to do this is:
$ beforeDot = array_shift (explosion ('.', $ String));
Comments
Post a Comment