Jump to content

[SOLVED] Finding amount of lines in a post


Cless

Recommended Posts

I need to find out how many lines are within a forum post upon my site (which is a custom-made forum). For example:

 

<?PHP

$string="Line 1.
Line 2.
Line 3.";

?>

 

Bad example, obviously, but anyway, that string has three lines... I need to count how many lines are within a string. So,

 

<?PHP

$string="bleh
moo
k
hi
spam";

?>

 

That string has five lines... so, if, for example, it was something that doesn't have an obvious amount of lines, like a forum post, I would need some sort of way to count how many lines are in that post.

based on your example.. this will be inpreted as 1 line only..

 

$string="bleh
moo
k
hi
spam";

 

unless you have "\n" inside the var..

 

 

Wrong.  The \n would be in the source file.

 

 

 

count(explode("\n", $str));

 

Will give you how many lines.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.