Find this something and replace what comes after it
<p>Basically I want PHP to open a config file, search for a string  and replace what comes after
The problem that I have in the code that I have created is that it finds  the string <code>$db_pass =</code> and is able to replace it... but then in the file there is an extra  <code>"password");</code> line... so i need it to be able to replace the entire line or either cut the rest to be able to delete it.</p>

<pre><code>    $dbFile = 'dbconfig.php';
    $String = "\$db_pass =\"new_password\";\n";
    file_put_contents($dbFile, str_replace("\$db_pass =", $String,    file_get_contents($dbFile)));
</code></pre>

<p>dbconfig.php</p>

<pre><code>    &lt;?php
    // Database Constants
    db_pass = "hi";
    db_user = "hssi";
?&gt;
</code></pre>

<p>my current script outputs like this
dbconfig.php</p>

<pre><code>       &lt;?php
    // Database Constants
    db_pass = "new_password";
"hi";
    db_user = "hssi";
?&gt;
</code></pre>
