'Search for next entry in text file based on array value from previous preg_match search

Ok so I have a log file that contains info like below

7:04:49 | Player "PLAYER A"(id=BC843EF4A109D1FE413E69FCCD789A2044224192) has been 
disconnected
07:05:03 | Player "PLAYER B" is connected (id=0EFCEFBB9F30A04B0BAA08E97766C368F9652642)
07:05:27 | ##### PlayerList log: 9 players
07:05:27 | Player "PLAYER B" (id=72C79B428E4A6DA8E1A915A20BEC65A3B993B072 pos=<2046.0, 14926, 439.1>)

Now I am searching the log for the player is connected lines This works and heres the code

 $coordpattern = '/^(.*?)Player (.*?) is connected/m';
            if(preg_match_all($coordpattern, $file, $items))
            {
             $logins = array();
             $i = 0;
                foreach($items[$i] as $item=>$val) {
                preg_match('/"([^"]+)"/',$val,$player);
                $time = substr($val,0,8);
                $offset = strpos($file,$val);
                //echo "<pre>";
                //echo $time.' - '.$player[0];
                //echo "</pre>";
                $logins[] = array("Time"=>$time,"Player"=>$player[0],"offset"=>$offset);
                $i++;
                }
            }

This is then building an array containing the Time, Player Name and strpos of the start of the line ( I assume )

What I want to then do is to search the log for any lines after the player is connected that match the player name. I'm trying to check the time from the start of the line and if its greater than the time in the logins array then just echo "found" However its just not returning anything..

Heres my code

foreach($logins as $playername){
    //echo $playername["Player"].'<br>';
    //var_dump($logins);
    //echo $playername[$l]['Player']."<br>";
    $player = str_replace('"','',$playername["Player"]);
    $logintime = $playername["Time"];
        $pospattern = '/^(.*?)Player \"'.$player.'\" \(id=(.*?) pos=<(.*?),(.*?),(.*?)\)/';
            if(preg_match_all($pospattern, $file, $positions))
            {
             $s = 0;
                foreach($positions[$s] as $pos=>$val) {
                $login = intval(str_replace(":","",$logintime));
                preg_match('/"([^"]+)"/',$val,$player);
                $time = substr($val,0,8);
                $actualtime = intval(str_replace(":","",$time));
                if($actualtime > $login)
                {
                    echo "found";
                }
                $s++;
                }
            }
        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source