$intersect = array_intersect($log_file_array[$code],$numbers);

should be

$intersect = array_intersect($log_file_array,$numbers);

---John Holmes...

----- Original Message -----
From: "Didier McGillis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 22, 2003 4:23 PM
Subject: Re: [PHP] HELP HELP on a file parser


> Fixed a couple of things in the code.  Pretty good for psudo code.  :)
>
> But I get this error when running.
>
> Warning: Argument #1 to array_intersect() is not an array in
> /home/httpd/vhosts/mccullough-net.com/httpdocs/GH/parse2.php on line 27
>
> Warning: Wrong datatype in array_flip() call in
> /home/httpd/vhosts/mccullough-net.com/httpdocs/GH/parse2.php on line 32
>
> code below.  any thoughts on what might be choking it.
>
> <?
> //read numbers
> $numbers = file("bad.txt");
>
> //read all lines from log file
> $fp = fopen("file2.log","r");
> $log_file = fread($fp,filesize("file2.log"));
>
> $results = fopen ("results.txt", "w");
>
> //match lines of log_file that start with 'code'
> //and match number
> preg_match_all("/^(code.*number=([0-9]+).*)$/m",$log_file,$matches);
>
> //put matches into an array such as
> // $array[code] = number
> $x=0;
> foreach($matches[1] as $code)
> {
>   $number = $matches[2][$x++];
>   $log_file_array[$code] = $number;
> }
>
> //compute intersection of log file array
> //and numbers array
> $intersect = array_intersect($log_file_array[$code],$numbers);
>
> //flip the log array, so you now have
> //an array full of the lines in the log
> //file that matches a number in the in.txt file
> $answer = array_flip($intersect);
> fwrite ($results, $answer);
>
>
>
>
>
> >From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> >Reply-To: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> >To: "Didier McGillis" <[EMAIL PROTECTED]>
> >CC: <[EMAIL PROTECTED]>
> >Subject: Re: [PHP] HELP HELP on a file parser
> >Date: Wed, 22 Jan 2003 16:07:17 -0500
> >
> >Okay, if I understand everything correctly, something like this may work,
> >if
> >you can get around the issue of your file sizes being so large, and you
can
> >deal with the amount of memory this is going to eat up, and you realize
> >that
> >Perl is probably better suited to the job...
> >
> >//read numbers
> >$numbers = file("in.txt");
> >
> >//read all lines from log file
> >$fp = fopen("file.log","r");
> >$log_file = fread($fp,filesize("file.log"));
> >
> >//match lines of log_file that start with 'code'
> >//and match number
> >preg_match_all("/^(code.*number=([0-9]+).*)$/m",$log_file,$matches);
> >
> >//put matches into an array such as
> >// $array[code] = number
> >$x=0;
> >foreach($mathes[1] as $code)
> >{
> >   $number = $matches[2][$x++];
> >   $log_file_array[$code] = $number;
> >}
> >
> >//compute intersection of log file array
> >//and numbers array
> >$intersect = array_intersect($log_file_array,$numbers);
> >
> >//flip the log array, so you now have
> >//an array full of the lines in the log
> >//file that matches a number in the in.txt file
> >$answer = array_flip($intersect);
> >
> >Hope that works... I can't test it. There are many ways you can do
this...
> >
> >--John Holmes...
> >----- Original Message -----
> >From: "Didier McGillis" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Tuesday, January 21, 2003 5:49 PM
> >Subject: Re: [PHP] HELP HELP on a file parser
> >
> >
> > > Sorry should have done this.
> > >
> > > in.txt (there will be 470 of these #'s) - it uses these numbers to
check
> > > against the chek.txt file
> > > 455784
> > > 455785
> > > 455786
> > > 455787
> > > 455788
> > >
> > > check.txt - after it checks this file where number=389487 a number
from
> > > in.txt, if it does it writes that to another file
> > > not on q/n2 24 Sat Nov 12 00:27:34 2002
> > > 3 129 code=001;number=389487;name=Blah L
> > > McBlah;type=5;big_number=888888888;time=09;min=2004;
> > >
> > >
> > > found.txt gets written to either in this format
> > > not on q/n2 24 Sat Nov 12 00:27:34 2002
> > > 3 129 code=001;number=389487;name=Blah L
> > > McBlah;type=5;big_number=888888888;time=09;min=2004;
> > > or this format
> > > code=001;number=389487;name=Blah L
> > > McBlah;type=5;big_number=888888888;time=09;min=2004
> > >
> > > hope that helps.
> > >
> > >
> > > >From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > > >Reply-To: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > > >To: "Didier McGillis" <[EMAIL PROTECTED]>,
> ><[EMAIL PROTECTED]>
> > > >Subject: Re: [PHP] HELP HELP on a file parser
> > > >Date: Tue, 21 Jan 2003 17:33:36 -0500
> > > >
> > > > > I need some help, I think this is probably really simple and I was
> > > >wondering
> > > > > if anyone had some code I could use to help me write this.
> > > > >
> > > > > I need a page to parse a text file with a list of numbers, and
then
> >take
> > > > > those numbers and parse another file with over 7MB of information
> >and
> >to
> > > > > look for those numbers and then to pull out the matches.  Now the
> >file
> > > >that
> > > > > its looking through each record that has a number in it is in a
> >specific
> > > > > format with a beginnning and an end.
> > > >
> > > >Can you give a short example of each file and what you want to match
in
> > > >each?
> > > >
> > > >---John Holmes...
> > > >
> > > >
> > > >--
> > > >PHP General Mailing List (http://www.php.net/)
> > > >To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > > _________________________________________________________________
> > > STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
> > > http://join.msn.com/?page=features/junkmail
> > >
>
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to