# preg\_match and preg\_replace problem

**URL:** <https://forum.kirupa.com/t/preg-match-and-preg-replace-problem/265796>\
**Category:** programming\
**Created:** [July 12, 2008, 5:15pm UTC](https://forum.kirupa.com/t/preg-match-and-preg-replace-problem/265796 "2008-07-12T17:15:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![utsav](https://avatars.discourse-cdn.com/v4/letter/u/e19b73/32.png) [@utsav](https://forum.kirupa.com/u/utsav)\
**Post date:** [July 12, 2008, 5:15pm UTC](https://forum.kirupa.com/t/preg-match-and-preg-replace-problem/265796/1 "2008-07-12T17:15:34Z")

</div>

Well i’ll try and explain my problem in as detail as possible. Here it goes.

I have a [COLOR=red]config.php[/COLOR] file that has variables stored in it as

```php
<?php 
 $host = "localhost";
 $user = "root";
 $pass = "";
 $dbname = "abc";
?>

```

Now i have another php file with 4 textboxes each for a variable in config.php file.

What i want to do is on click of the save button on this page. I want [COLOR=darkorange]textbox1[/COLOR] value to replace [COLOR=blue]localhost[/COLOR] , [COLOR=darkorange]textbox2[/COLOR] value to replace [COLOR=blue]root[/COLOR] , and on… ,I know i need to use preg\_match and preg\_replace. but dont know how ?? So a fully explained help with codes would be helpfull so as i could see and learn.

Thanks!!!
