remove last part of email address

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts

  • schwooba@gmail.com
    Guest replied
    Re: remove last part of email address

    matturbanowski "explode" option worked great. Thanks for everyone's
    input.


    Petr Vileta wrote:
    <schwooba@gmail .compíse v diskusním príspevku
    news:1167921087 .901015.39030@4 2g2000cwt.googl egroups.com...
    Is there a simple way to remove the last part of an email address using
    PHP. I want to remove the @ symbol and everything to the right of it.
    Any ideas?

    Example:

    thomas@xyz.com

    should be:

    thomas
    $email = preg_replace('/^(.+?)\@.+$/', '$1', $email);
    --
    >
    Petr Vileta, Czech republic
    (My server rejects all messages from Yahoo and Hotmail. Send me your mail
    from another non-spammer site please.)

    Leave a comment:


  • Petr Vileta
    Guest replied
    Re: remove last part of email address

    <schwooba@gmail .compíse v diskusním príspevku
    news:1167921087 .901015.39030@4 2g2000cwt.googl egroups.com...
    Is there a simple way to remove the last part of an email address using
    PHP. I want to remove the @ symbol and everything to the right of it.
    Any ideas?
    >
    Example:
    >
    thomas@xyz.com
    >
    should be:
    >
    thomas
    >
    $email = preg_replace('/^(.+?)\@.+$/', '$1', $email);
    --

    Petr Vileta, Czech republic
    (My server rejects all messages from Yahoo and Hotmail. Send me your mail
    from another non-spammer site please.)


    Leave a comment:


  • ZeldorBlat
    Guest replied
    Re: remove last part of email address


    schwooba@gmail. com wrote:
    Is there a simple way to remove the last part of an email address using
    PHP. I want to remove the @ symbol and everything to the right of it.
    Any ideas?
    >
    Example:
    >
    thomas@xyz.com
    >
    should be:
    >
    thomas
    >
    Thanks!
    Someone here will inevitably suggest a regex, but that's overkill:

    $email = 'foo@bar.com';
    $username = substr($email, 0, strpos($email, '@'));

    Leave a comment:


  • matturbanowski
    Guest replied
    Re: remove last part of email address

    This is one way of doing it...

    $temp = explode("@", $email);
    echo $temp[0];

    Leave a comment:


  • schwooba@gmail.com
    Guest started a topic remove last part of email address

    remove last part of email address

    Is there a simple way to remove the last part of an email address using
    PHP. I want to remove the @ symbol and everything to the right of it.
    Any ideas?

    Example:

    thomas@xyz.com

    should be:

    thomas

    Thanks!

Working...