On Fri, 31 Jan 2003, Maxim Maletsky wrote:

> > need a random line stamp?
> > useful for humour stories :-)
> > 
> > <?
> > $file = file("/path/to/your/file");
> > 
> > mt_srand ((double) microtime() * 1000000);
> > $line = mt_rand(0,count($file));
> > 
> > echo $file[$line];
> > ?>

> Philip,
> 
> Why have you removed this (and #28378) notes? 
> 
> They weren't that wrong, perhaps could be edited for perfection. They
> were quite short in size, and its rare.
> 
> I'd get rid of a few big long notes, even if they are useful, but would
> leave several handy small notes for the users to see how various things
> can be accomplished. That helps.

This depends on your view of the notes system.  It's purpose 
is for people noting improvements to the manual page itself,
not a repository for code snippets (long, short or otherwise).
But I also leave some useful examples, and many notes or 
implement them straight into the manual.  The PHP community
at large is where additional code snippets as it's not the job
of the PHP manual nor should it be.

I removed this one in particular because someone posted a correct
one with explanation of the problem so I left that one.  

I removed note #28378 because it was silly and blatently
wrong and a correct version already exists as an official
example:

  // Explains the bogus #28378 note
  http://news.php.net/article.php?group=php.notes&article=43158

My actions were appropriate and IMHO even too conservative
but anyway that's my story.  On a related note, I feel
these notes teach the user that to simply get the number
of lines of a file, they should load the entire file
into memory and do a count on it.  Not ideal for situations
where just the number of lines is needed, such as picking
a random line number.  In which case use fopen/fgets and
`wc -l` but that gets overcomplicated and beyond the scope
of a note.  I did start on a reply but got distracted
worrying about win32, safe_mode, and efficiency in relation
to filesize ... so I just stopped but left the note.  Also
it might give people ideas like "Oh, I think I'll add a
cool feature to my site that tells people how many lines
are in a file so I'll use this file() function for that."

Regards,
Philip




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

Reply via email to