Cless Posted April 6, 2009 Share Posted April 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/152713-solved-finding-amount-of-lines-in-a-post/ Share on other sites More sharing options...
vbnullchar Posted April 6, 2009 Share Posted April 6, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/152713-solved-finding-amount-of-lines-in-a-post/#findComment-801960 Share on other sites More sharing options...
corbin Posted April 6, 2009 Share Posted April 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/152713-solved-finding-amount-of-lines-in-a-post/#findComment-801962 Share on other sites More sharing options...
Cless Posted April 6, 2009 Author Share Posted April 6, 2009 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/152713-solved-finding-amount-of-lines-in-a-post/#findComment-801967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.