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 (john@smith.com) 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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.