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

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -