Jump to content

Parsing information from strings


soadlink

Recommended Posts

Hello,

Before I ask this quick question, I'll just mention that i did search google and the forums, but did not find exactly what i was looking for, so here goes:

I am looking for a method to parse an email address out of a string of data. Since email addresses can be various legnths, I dont think using something like substr() will work. Is there a method to pull out a string of data using 'before' and 'after' strings?

For example a string can look like this: [i][b]5345345534883\email\test@email.com\sig\[/b][/i]

So I'm looking for something that could use '\email\' as a before, and \sig\ as an after, and pull out whatever is in the middle of that. In this case, it would be the email.

Im sure there is a particular function to do that, I just dont know what it is  ???

Thanks for the help!
Link to comment
Share on other sites

Wintergreen,

Thank you very much. I actually figured it out with explode. For every \, I actually needed to specify it as 2 backslashes \\.

My code ended up being:

[code]
$array = explode("\\", $third);
echo $array[10];[/code]

$third being the string I was exploding. "\\" was to explode it at every \ in that string.
And the 10 is because the 10th instance of a "\" in my string is where the email is.

Thanks again for the helping!
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.