Jump to content

Extracting info between brackets


mckeegan375

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.