...

View Full Version : line numbers



GO ILLINI
01-07-2006, 06:44 AM
I know there was someting on php.net about line numbers...
It was an example in the functions. I was searching and I saw it and didnt really care because that was not what I was looking for. Now I am, but I cant find it again. Does anyone have any ideas? What I want is the source with line numbers...




Thanks,
ILLINI

Velox Letum
01-07-2006, 06:47 AM
Line numbers? Just explode the text by \n and foreach the array.


$text = 'Foo
Bar
Is
Bar
Foo';
$text_array = explode("\n", $text);
foreach ($text_array as $key => $line) {
echo 'Line ' . $key + 1 . ': ' . $line . '<br />' . "\n";
}

GO ILLINI
01-07-2006, 06:58 AM
Would there be an easy way to just plug a filename in there instead of copy and pasteing?



ILLINI

GO ILLINI
01-07-2006, 07:04 AM
I found it!
http://us3.php.net/manual/en/function.file.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum