ereg replace?

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

    ereg replace?

    I have a blog type script, I would like to make it automaticly parse img
    files in the blog entry somehow (ie; If I put "http://www.test.com/me.jpg"
    it will parse it as "<img src="http://www.test.com/me.jpg" border=0
    width="135">"


    I'm new to PHP I have read about ereg and other functions like it but I'm
    not sure how to achieve this, the output of my blog is from this



    <?php echo $vEntries[$i]['entry']; ?>


    Any help would be greatly appreciated.
    - Jason


  • Markus L.

    #2
    Re: ereg replace?

    Am Fri, 08 Jul 2005 21:49:31 +0000 schrieb JD:
    [color=blue]
    > I have a blog type script, I would like to make it automaticly parse img
    > files in the blog entry somehow (ie; If I put "http://www.test.com/me.jpg"
    > it will parse it as "<img src="http://www.test.com/me.jpg" border=0
    > width="135">"
    >
    >
    > I'm new to PHP I have read about ereg and other functions like it but I'm
    > not sure how to achieve this, the output of my blog is from this
    >
    >
    >
    > <?php echo $vEntries[$i]['entry']; ?>
    >
    >
    > Any help would be greatly appreciated.
    > - Jason[/color]

    <?php
    echo preg_replace('/(http:\/\/)([^ ]+)(\.jpg)/i', '<img src="$1$2$3"
    border="0" width="135">', $vEntries[$i]['entry']);
    ?>

    --
    -------------------------------------------------------
    Try this: SCA the Smart Class Archive for PHP

    -------------------------------------------------------

    Comment

    Working...