If I remove the "/" then I get this error

Warning: bad regular expression for split() in
/home/virtual/browse/home/httpd/html/Classifieds/infobox2.php on line 14


----- Original Message -----
From: Kevin Stone <[EMAIL PROTECTED]>
To: WebDev <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, March 06, 2003 12:40 PM
Subject: Re: [PHP] reading last -n lines array is emty


> No you did not do it as I described.
>
> Here's what I wrote:
> split('|', $line[$i]);
>
> Here's what you wrote:
> split('\|', $line[$i]);
>
> See the difference?  Remember single quotes denote a literal.  You do not
> have to limit the pipe character when you use single quotes.
>
> - Kevin
>
> ----- Original Message -----
> From: "WebDev" <[EMAIL PROTECTED]>
> To: "Kevin Stone" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Thursday, March 06, 2003 4:33 PM
> Subject: Re: [PHP] reading last -n lines array is emty
>
>
> > still empty
> >
> > Got the code like you described:
> >
> > // start
> >
> > $file = file("data/ads.data");
> >
> > $num_lines = count($file);
> > if ($num_lines > 10)
> >     $start_line = $num_lines - 10;
> > else
> >     $start_line = 0;
> > for ($i=$start_line; $i<$num_lines; $i++)
> > {
> > list($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei, $vier,
> > $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat,
> > $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
> > $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei,
> > $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split('\|', $line[$i]);
> >
> > echo "Line #$i. \n <br>";
> > print "<a
> >
>
href=\"http://www.browseabit.com/cgi-bin/Classifieds/classifieds.cgi?session
> > _key=&search_and_display_db_button=on&db_id=$adnr&query=retrieval\"
> > target=\"_blanko\">$Endzwei $End3</a><br>";
> >     }
> >
> >
> > // end
> > ----- Original Message -----
> > From: Kevin Stone <[EMAIL PROTECTED]>
> > To: browseabit <[EMAIL PROTECTED]>
> > Sent: Thursday, March 06, 2003 12:15 PM
> > Subject: Re: [PHP] reading last -n lines array is emty
> >
> >
> > > $buffer is undefined in your code.  Do split('|', $line[$i]);
> > > - Kevin
> > >
> > > ----- Original Message -----
> > > From: "browseabit" <[EMAIL PROTECTED]>
> > > To: "Kevin Stone" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > > Sent: Thursday, March 06, 2003 4:09 PM
> > > Subject: Re: [PHP] reading last -n lines array is emty
> > >
> > >
> > > >
> > > > I again have no values in my list names $adnr, $user, $date,
$listed,
> > > > $hlong, $eins, $zwei, ..... themn are always emty no matter what I
do
> > with
> > > > your code my code
> > > >
> > > >
> > > >
> > > > // code start
> > > > $file = file("data/ads.data");
> > > >
> > > > $num_lines = count($file);
> > > > if ($num_lines > 10)
> > > >     $start_line = $num_lines - 10;
> > > > else
> > > >     $start_line = 0;
> > > > for ($i=$start_line; $i<$num_lines; $i++)
> > > > {
> > > > list($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
$vier,
> > > > $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
> $ClassCat,
> > > > $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
> > > > $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
$dreizwei,
> > > > $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split ("\|",
$buffer);
> > > > echo "Line #$i.\n <br>";
> > > > print "<a
> > > >
> > >
> >
>
href=\"http://www.browseabit.com/cgi-bin/Classifieds/classifieds.cgi?session
> > > > _key=&search_and_display_db_button=on&db_id=$adnr&query=retrieval\"
> > > > target=\"_blanko\">$Endzwei $End3</a><br>";
> > > >     }
> > > >
> > > >
> > > > // Code end
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: Kevin Stone <[EMAIL PROTECTED]>
> > > > To: WebDev <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > > > Sent: Thursday, March 06, 2003 11:42 AM
> > > > Subject: Re: [PHP] reading last -n lines array is emty
> > > >
> > > >
> > > > > You could do it reading back to front the way you propose but I
> think
> > it
> > > > > will work much better in a proper for loop.
> > > > >
> > > > > // the number of elements in the array.
> > > > > $num_lines = count($file);
> > > > >
> > > > > // the line we want to start the loop at.
> > > > > if ($num_lines > 10)
> > > > >     $start_line = $num_lines - 10;
> > > > > else
> > > > >     $start_line = 0;
> > > > >
> > > > > // loop through the array
> > > > > for ($i=$start_line; $i<$num_lines; $i++)
> > > > > {
> > > > >     echo "Line #$i.\n";
> > > > >     file://do your work here..
> > > > > }
> > > > >
> > > > > Hope that helps.
> > > > >
> > > > > - Kevin
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "WebDev" <[EMAIL PROTECTED]>
> > > > > To: <[EMAIL PROTECTED]>
> > > > > Sent: Thursday, March 06, 2003 3:24 PM
> > > > > Subject: [PHP] reading last -n lines array is emty
> > > > >
> > > > >
> > > > > How to grab the last -n lines from a data file and display the
> stored
> > > data
> > > > > Only the the last 10 line numbers coming back when I echo $i
> > > > >
> > > > > How do I get the list($adnr, $user, $date, $listed  .... to catch
> the
> > > > > datafields
> > > > >
> > > > > datafile looks like
> > > > > 23|Werner|LastN|Street|etc|etc.|etc||||||
> > > > > 24|Veronika||||
> > > > >
> > > > > // code start
> > > > >
> > > > >
> > > > > $file = file("data/ads.data");
> > > > > for ($i = count($file); $i > count($file) - 10; $i--)
> > > > > foreach($i as $line) {
> > > > > list($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
> $vier,
> > > > > $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
> > $ClassCat,
> > > > > $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
$End3,
> > > > > $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
> $dreizwei,
> > > > > $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split ("\|",
> $buffer);
> > > > >
> > > > > print " $i  <a
> > > > >
> > > >
> > >
> >
>
href=\"classifieds.cgi?session_key=&search_and_display_db_button=on&db_id=$a
> > > > > dnr&query=retrieval\" target=\"_blanko\">$Endzwei $End3</a> <br>";
> > > > >
> > > > > };
> > > > >
> > > > > // Code end
> > > > >
> > > > >
> > > >
> > >
> >
>


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

Reply via email to