Re: using image place holders in a database field?
| From: | Philip Murray | Date: | Wed, 11 Jul 2001 04:07:09 +0000 |
| Subject: | Re: using image place holders in a database field? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-57303@lists.php.net to get a copy of this message | ||
Oops. That should've been
$string = ereg_replace("##([^#]+)##", "<img src=\"\\1\">",
$string);
----- Original Message -----
From: "Philip Murray" <me@philth.net.nz>
To: "Matthew Delmarter" <matt@adplusonline.com>
Cc: <php-general@lists.php.net>
Sent: Wednesday, July 11, 2001 3:57 PM
Subject: Re: [PHP] using image place holders in a database field?
> This should do it for you
>
> <?
>
> $string = "Here is a picture ##flowers.jpg## of some flowers";
> $string = ereg_replace("##(.+)##", "<img src=\"\\1\">",
> $string);
>
> print($string);
> // prints 'Here is a picture <img src="flowers.jpg"> of some flowers'
>
> ?>
>
> The "##(.+)##" parts matches any string with two # at the start and the
end,
> the <img src=\"\\1\"> part replaces the ##string## with <img
src="string">.
> The \\1 is a reference to the string matched with (.+) in the first
> parameter. '.+' matches any character 1 or more times.
>
> -------------------------------- - -- - - -
> Philip Murray
> me@philth.net.nz
> ------------- - -- - -
>
> ----- Original Message -----
> From: "Matthew Delmarter" <matt@adplusonline.com>
> To: "PHP Mailing List" <php-general@lists.php.net>
> Sent: Wednesday, July 11, 2001 3:47 PM
> Subject: [PHP] using image place holders in a database field?
>
>
> > Hi all,
> >
> > I want to use image place holders in a mysql field. The field will store
a
> > newsletter article and I want to include and display an image in the
> > article.
> >
> > For example I will have:
> > "the article text ##image_name## some more article text".
> >
> > I will use str_replace to replace ##image_name## with the html tag to
> > display such as <img src='/images/image_name'>.
> >
> > But - I don't know how to write the str_replace! Can anyone help?
> >
> > Also, is there are better way to do this?? Can I have images displayed
in
> > the middle of text from a field some other way?
> >
> > I also cannot seem to find much on using place holders in a field - but
I
> > can see it's advantages.
> >
> > I hope this all makes sense...
> >
> > Regards,
> >
> > Matthew Delmarter
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>