Solved

Restrict Textarea Input

Posted on 2006-10-31
1
209 Views
Last Modified: 2008-03-03
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
Comment
Question by:phpdotnet
1 Comment
 
LVL 10

Accepted Solution

by:
rivusglobal earned 250 total points
ID: 17840882
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question