mckeegan375 Posted November 15, 2010 Share Posted November 15, 2010 Hi Ive been trying to solve this problem for a few hours but am having no luck so would appreciate any help Im looking for a function/way of extracting info from a dropdown list when a form is submitted. The form field has a name and email address i.e John ([email protected]) and i just need the email address part to submit into a mysql database. I tried using the explode() function but this didnt work. Any ideas? Cheers Andy Link to comment https://forums.phpfreaks.com/topic/218779-extracting-info-between-brackets/ Share on other sites More sharing options...
ManiacDan Posted November 15, 2010 Share Posted November 15, 2010 preg_match. Explode works too if you combine it with trim(). -Dan Link to comment https://forums.phpfreaks.com/topic/218779-extracting-info-between-brackets/#findComment-1134677 Share on other sites More sharing options...
mckeegan375 Posted November 15, 2010 Author Share Posted November 15, 2010 Cheers Dan - worked a treat! Andy Link to comment https://forums.phpfreaks.com/topic/218779-extracting-info-between-brackets/#findComment-1134684 Share on other sites More sharing options...
Maq Posted November 15, 2010 Share Posted November 15, 2010 Cheers Dan - worked a treat! Andy Mind sharing so people can use this thread as a reference in case they run into the same problem? Link to comment https://forums.phpfreaks.com/topic/218779-extracting-info-between-brackets/#findComment-1134686 Share on other sites More sharing options...
mckeegan375 Posted November 15, 2010 Author Share Posted November 15, 2010 Sure, no problem. So my form had a dropdown field called 'email' but the data in the dropdown was in the format Name (email) and i just wanted the email part for my query. So using Dan's suggestion of explode and trim, i got the following: $start = $_POST['email']; $emailexplode = explode("(",$start); $email = rtrim($emailexplode[1],")"); Hope this helps someone in the future Andy Link to comment https://forums.phpfreaks.com/topic/218779-extracting-info-between-brackets/#findComment-1134708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.