I can't seem to find the right function to search a string. I want to grab the email out of the error code and then display that to the user but the function I am using returns everything after the string is found also. What function can I use to only return what I am looking for?
The output of the below code is firstname.lastname@example.org' for key 'PRIMARY' has already been registered. I only want email@example.com returned.
//Grabs the error message
$errorMessage = mysqli_error($dbConnect);
//grabs the email from the error mesage
$usedEmail = strstr($errorMessage, $email);
// tells users email has already been used.
$regMessage = $usedEmail . " has already been registered";