I have a database that has names and I want to use PHP replace after the space on names, data example:
$x="Laura Smith";
$y="John. Smith"
$z="John Doe";
I want it to return
Laura
John.
John
I have a database that has names and I want to use PHP replace after the space on names, data example:
$x="Laura Smith";
$y="John. Smith"
$z="John Doe";
I want it to return
Laura
John.
John
The method provided by TheBlackBenzKid is valid for the question - however when presented with an argument which contains no spaces, it will return a blank string.
Although regexes will be more computationally expensive, they provide a lot more flexibiltiy, e.g.:
$x="Laura Smith"; $temparray = implode(' ', $x); echo $temparray[0];I'm sorry, sometimes mix up implode and explode...