How to 'grep' one portion of a line out by php script?
<p>I have a little problem. I have written php script and javascript that allows me to 'grep' line using function of the 'date', but is it possible to just grep one portion of the line out only? </p>

<p>For example, I have taken out this line from report.txt(Which is simply a log file) using the date's function(2010-11-06) and put it in a new text file(Testing.txt): </p>

<p><code>ToHoneynet 2010-11-06 10:51:48.0   ICMP PING   3   url www.snort.org/pub-bin/sigs.cgi?sid=384  134.25.234.23   8   1   115.42.150.38   0   1</code></p>

<p>From here, I would like to 'grep' and write the IP address: 134.25.234.23 out only. How am I going to do it? </p>

<p>Below are my PHP script and javascript. Thanks! </p>

<p>//Read date value </p>

<pre><code>function checkDate(Date)
{
var date = /^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$/;
if (date.test(Date))
{
    var dates = "y=" + Date;
    $.post("date.php", dates, function(data)
    {
            alert("Searching for Date... ");    
    });
}
        else
        {
                alert("Invalid Date");
        }   
}
</code></pre>

<p>//date.php
    

<pre><code>foreach ($lines as $line_num =&gt; $line)
{
    $pos = strpos($line,$Date1);

    if($pos === false) 
    {
        echo "Cannot grab line";
    }
    else
    {

    $myFile = "Testing.txt";        
    $fh = fopen($myFile, 'w') or exit ("Cannot open File");
    fwrite($fh, $line);
    fclose($fh);

    }

}
</code></pre>

<p>?></p>
