feature request

From: Date: Wed, 24 Apr 2002 18:20:47 +0000
Subject: feature request
Groups: php.dev 
Request: Send a blank email to php-dev+get-83267@lists.php.net to get a copy of this message
It would be great if there was a function in the filesystem family similar to the unix command "wc". It'd be nice to not have to write simple wrappers around system calls or creating arrays to get the number of words or lines in a file. For example, to get the number of lines in a file, I have to do this: // bash specific solution function lines($filename) { $wc = bash -c 'wc -l $filename 2>&1'; return (preg_match("|^\s+(\d+)\s+$filename\s*$|", $wc, $matches)? $matches[1] : 0; } or this: // generic solution (w/o error checks): function lines($filename) { return count(file($filename)); } Take care, Nik

« previous php.dev (#83267) next »