On Wed, Oct 15, 2003 at 04:16:14AM -0500, Gabriel Peugnet wrote:
:
: Thanks Eugene.
:
: I'm afraid I didn't explain my self as I should.
:
: What I want is this to be automaticaly generated in a text.
: For example, in:
:
: "Some text some text some text some text [EMAIL PROTECTED] some text some text
: some text and www.mywebpage.com some text some text some text
: [EMAIL PROTECTED] some text some text some text ."

You're so close...

    <?php
    function emaillink($email)
    {
        $email = htmlentities($email);
        return '<a href=\'mailto:' . $email . '\'>' . $email .  '</a>';
    }
    function emaillink_callback($matches)
    {
        return emaillink($matches[0]);
    }
    $word = "Some text some text some text some text [EMAIL PROTECTED] some text some 
text some text and www.mywebpage.com some text some text some text [EMAIL PROTECTED] 
some text some text some text ."
    echo preg_replace_callback('|([EMAIL PROTECTED])|', 'emaillink_callback', $word) . 
"\n";
    ?>

Of course, the equivalent code for web sites is left as an exercise.
But you get the idea.  :-)  The tough part is figuring out the regular
expression pattern.


: "Gabriel Peugnet" asked:
: >
: > I want to convert
: >     [EMAIL PROTECTED]
: > into
: >     (a href='mailto:[EMAIL PROTECTED]') [EMAIL PROTECTED] (/a)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to