# Foreach and str\_replace

**URL:** <https://forum.kirupa.com/t/foreach-and-str-replace/288597>\
**Category:** Uncategorized\
**Created:** [May 18, 2009, 7:27pm UTC](https://forum.kirupa.com/t/foreach-and-str-replace/288597 "2009-05-18T19:27:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![philsbury](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@philsbury](https://forum.kirupa.com/u/philsbury)\
**Post date:** [May 18, 2009, 7:27pm UTC](https://forum.kirupa.com/t/foreach-and-str-replace/288597/1 "2009-05-18T19:27:51Z")

</div>

Hi,

I’m trying to replace a placeholder of text in a template with a list of articles from a database - I know it possible I just can’t figure it out.  
eg.

```php
foreach ($record as $news) { 
             $page = str_replace('{month}', date('M', $news['posted']), $page);
            }

```

$page being the html loaded into a variable. I’m fairly sure it’s doing once, then stopping as the string no longer exists, but how can I duplicate the string?

Thanks  
Phil
