Writing to a Text File (PHP)
<p>I know this question is probably straightfoward but I'm new to php and programming...
I want to write the results of a recursive search to a text file, and also ensuring that any other search performed will not overwrite the exisiting data, but add to it.</p>

<p>here is my code:</p>

<pre><code> &lt;?php 

$it = new RecursiveDirectoryIterator("L:\folder\folder\folder"); 
$display = Array ( 'jpeg', 'jpg', 'tif', 'tiff', 'bmp', 'shp', 'gif', 'png' ); 
foreach(new RecursiveIteratorIterator($it) as $file) 
{ 
    if ( In_Array ( SubStr ( $file, StrrPos ( $file, '.' ) + 1 ), $display ) == true )
    { 
        echo $file . "&lt;br/&gt; \n"; 
    }
}

?&gt;
</code></pre>

<p>So instead of echoing the result, I'd rather it be written to a text file. Also, if it is possible, echo the result and write it to a text file. plz let me know what code I can add in to achieve this thanks :)</p>
