RE: [PHP] str_replace an include
| From: | Timothy Hitchens \(HiTCHO\) | Date: | Tue, 21 Jan 2003 15:14:25 +0000 |
| Subject: | RE: [PHP] str_replace an include | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132423@lists.php.net to get a copy of this message | ||
There a few ways of doing this but the following is one of the easier
and quickest off the
top of my head.
If you know the name of the tag and the include this will work if you
don't or want it to
be dynamic you will need to have some reg for the following. (how are
you getting the $string)?
// $string holds your html page you wish to replace
ob_start();
include('links.php');
$links = ob_get_contents();
ob_end_clean();
str_replace('<!--linkTag--!>', $links, $string);
echo $string;
I hope this gives you a direction.
Timothy Hitchens (HiTCHO)
Open Source Consulting
e-mail: tim@hitcho.com.au
> -----Original Message-----
> From: jesse [mailto:lawrence_jesse@yahoo.ca]
> Sent: Wednesday, 22 January 2003 1:05 AM
> To: php-general@lists.php.net
> Subject: [PHP] str_replace an include
>
>
> Hello all,
>
> I'm trying to replace a tag with an include in a template
> scenario. For
> example:
>
> str_replace("<!--linkTag--!>", include "links.php", $string);
>
> This obviously doesn't work, but I'm wondering if anybody knows of a
> good way to do this.
>
> Thanks a bunch,
>
> Jesse Lawrence
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>