Saasaan Saasaan - 1 year ago 96
PHP Question

Change string inside a PHP code

I have asked a question in this post

but it might look some confusing and I found no relative response, so I make it quiet simple.

the code is:

$newTitle = 'string retreved from somewhere';
fwrite($newFile, "<title>oldTitle</title>\n");

I want to replace

I have tried this:

$myTitle = preg_replace('/(<title>)(.*?)(<\/title>)', $newtitle, $myTitle);


Answer Source
fwrite($newFile, "<title>{$newTitle}</title>\n");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download