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 email@example.com' for key 'PRIMARY' has already been registered. I only want firstname.lastname@example.org 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";