Issue
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
Solution
Do this, this replaces anything after the space character. Can be used for dashes too:
$str=substr($str, 0, strrpos($str, ' '));
Answered By - TheBlackBenzKid Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.