• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Restrict Textarea Input

I want to use PHP to get only 10 lines of a textbox "links" and output " line x has ... ". Is it available & how to do ?
0
phpdotnet
Asked:
phpdotnet
1 Solution
 
rivusglobalCommented:
Hi phpdotnet,

Try this:

$i = 1;                                     // Start the line counter at 1
$text = $_REQUEST['links'];     //  Get the entire textbox data into $text
foreach( split( "\n", $text ) as $line ) {    // Split the textbox data by carriage return ( \n )
    print "Line " . $i++ . " has $line\n";          // Display the contents of this line
    if( $i >= 10 ) {                    // Stop printing lines once we've reach 10
        last;
    }
}
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now