# ereg\_replace?

**URL:** <https://forum.kirupa.com/t/ereg-replace/179929>\
**Category:** Uncategorized\
**Created:** [February 24, 2006, 12:42am UTC](https://forum.kirupa.com/t/ereg-replace/179929 "2006-02-24T00:42:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbrollwitme](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pbrollwitme](https://forum.kirupa.com/u/pbrollwitme)\
**Post date:** [February 24, 2006, 12:42am UTC](https://forum.kirupa.com/t/ereg-replace/179929/1 "2006-02-24T00:42:56Z")

</div>

hey all,  
i’m exporting a list of all my mySQL databases using php and trying to write them to an xml file. However, my server adds townfre\_ before the name of the database. I want to remove that from the name and leave the remainder of the database name to be written to the xml file. I’m using this:

```php
 $file= fopen("states.xml", "w+");
 $_xml .="<towns>
";
 while ($row = mysql_fetch_array($db_list)) {
 if ($row['0']) {
  $_xml .= "<town name=\{ereg_replace("townfre_","","$row['0']")} />
";
  } 
}

```

but, obviously its not working. Anyone know how i can achieve what i want here?  
Thanks,  
Mat
