Reading txt file with php
<p>I'm trying to pars ip in line which located 2 lines upper from specific words that I know, can somebody give an idea how to do it?
This is part of my code...</p>

<pre><code>if (($handle = fopen('FW1-20160802_1530.conf', "r")) !== FALSE){
while (($data = fgetcsv($handle, 1000,";")) !== FALSE) 
..
else if (preg_match('/(.*site-5552)/',$data[0],$match))
            {
                list(,$line)=$match;
                $REV_ARRAY[$site_name]['line']=$line;           
            }
</code></pre>

<p>That gives me the third line of the following output:</p>

<pre><code>edit 2
        set dst 10.23.255.252 255.255.255.252
        set device "abc"
        set comment "Static Route site-5552"
</code></pre>

<p>But as I mentioned above I need to catch the ip: "10.23.255.252" which exists two lines upper.</p>

<p>The text file is too big so I pasted just part of it.
According to site number (in this example- 5552) I need to find the relevant ip (10.93.255.252) </p>

<pre><code>edit "Site-5552"
    set asdaa
    set asdsdaa
    set aadsda
    set aasdda
    set aaaa
    set adsaa
    set aadsa
    set vvxv
    set dsds
    set czx
</code></pre>

<p>ssasd</p>

<pre><code>edit 2
        set dst 10.93.255.252 255.255.255.252
        set device "sdasdsad"
        set comment "Static Route for LTE site-5552"
</code></pre>