I have a string: $demo = 'john<br>doe'; i want to convert this into two strings: $1 = 'john'; $2 = 'doe'; So i need a line of code that searched the string for <br>, removes it (str_replace should be fine) and assign everything before it to $1 and everything after it to $2. How can this be done? I believe with regex but am not sure... thanks
You're better of using explode() in this case. list($name, $lastname) = explode('<br>', $demo); echo $name; // john echo $lastname; // doe PHP: