Re: Making a variable -Trim output
| From: | Clayton Dukes | Date: | Mon, 26 Feb 2001 17:32:43 +0000 |
| Subject: | Re: Making a variable -Trim output | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41711@lists.php.net to get a copy of this message | ||
Dan...
You are the man, thanks! :-)
----- Original Message -----
From: "Dan Olsen" <dolsen@informano.net>
To: "Clayton Dukes" <cdukes@cdukes.com>
Sent: Monday, February 26, 2001 12:30 PM
Subject: RE: [PHP] Making a variable -Trim output
>
> clayton-
>
> the only problems were syntactic.
>
> there was an extra $ on the filename for file.txt, and there were no $'s
on
> the loop variable i (happens to me all the time, switching from perl to
> java(script) to php depending on what day it is).
>
> this code compiles and runs fine.
>
> <?
>
> $arrayoflines = file('file.txt');
> $arraysize = sizeof($arrayoflines);
> $limit = $arraysize - 2;
> $output = "";
>
> for ( $i=0; $i<$arraysize; $i++) {
> if ( ($i>12) && ($i<$limit) ) {
> $output .= $arrayoflines[$i];
> }
> }
>
> print $output;
>
> ?>
>
> enjoy,
> DanO
>
>
>
> -----Original Message-----
> From: Clayton Dukes [mailto:cdukes@cdukes.com]
> Sent: Monday, February 26, 2001 9:08 AM
> To: Dan Olsen
> Subject: Re: [PHP] Making a variable -Trim output
>
>
> Thanks so much for your help Dan,
>
> here's what I get when I try it:
>
> Parse error: parse error, expecting `';'' in - on line 7
>
> line 7 is:
> for (i=0; i<\$arraysize; i++) {
>
> any ideas?
>
>
> ----- Original Message -----
> From: "Dan Olsen" <dolsen@informano.net>
> To: <php-general@lists.php.net>
> Sent: Monday, February 26, 2001 12:02 PM
> Subject: RE: [PHP] Making a variable -Trim output
>
>
> >
> > yes but you might want to use a for() loop instead since you know what
you
> > want.
> >
> > $arrayoflines = file("$file.txt");
> > $arraysize = sizeof($arrayoflines);
> > $limit = $arraysize - 2;
> >
> > for (i=0; i<$arraysize; i++) {
> > if ( (i>12) && (i<$limit) ) {
> > $output .= $arrayoflines[i];
> > }
> > }
> >
> > you'll have to debug, but it should work.
> >
> > DanO
> >
> >