How to merge two files in php while replacing the contents?
<p>I wanna know how to merge two files in php such that one final file is generated and have both changes, </p>

<p>example : </p>

<p>style.css</p>

<pre><code>#mydiv{
   background:white;
   color:black;
}
</code></pre>

<p>and</p>

<p>style2.css</p>

<pre><code>#mydiv{
   border:1px solid black;
}
</code></pre>

<p>and</p>

<p>final.css</p>

<pre><code>#mydiv{
   background:white;
   color:black;
   border:1px solid black;
}
</code></pre>

<p>So I want the <code>final.css</code> in output after merging <code>style.css</code> and <code>style2.css</code>,,</p>

<p>Note : CSS file is not my point, its just for example,, I want to do it with any kind of file Like merging files with both versions.</p>

<p>Another Example :</p>

<p>file1.js</p>

<pre><code>var x=90;
var y=50;
var z=x+y;
</code></pre>

<p>file2.js</p>

<pre><code>var z=x+y;
var yx=500; 
</code></pre>

<p>and</p>

<p>output.js</p>

<pre><code>var x=90;
var y=50;
var z=x+y;
var yx=500;
</code></pre>

<p>Thanks!</p>