Counting Rows in textarea

Posted by Johan Cyprich on 29 Jan 2008 | Tagged as: Programming

I wrote a snippet which counts the number of rows of text in an HTML textarea object. Its very useful if you need to display data outside of the textarea box.

I’ve got an example of a form and the PHP function it calls.

Filename: t.php


Filename: t_handler.php

$textarea = $_POST['ta'];

$check = explode("\n", $textarea);
$lines = count($check);

echo "Lines: $lines";


Related posts:
    AJAX and PHP: Building Responsive Web Applications

Share this post:

del.icio.us:Counting Rows in textarea digg:Counting Rows in textarea spurl:Counting Rows in textarea wists:Counting Rows in textarea simpy:Counting Rows in textarea newsvine:Counting Rows in textarea blinklist:Counting Rows in textarea furl:Counting Rows in textarea reddit:Counting Rows in textarea fark:Counting Rows in textarea blogmarks:Counting Rows in textarea Y!:Counting Rows in textarea smarking:Counting Rows in textarea magnolia:Counting Rows in textarea segnalo:Counting Rows in textarea gifttagging:Counting Rows in textarea

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply