Solved

Restrict Textarea Input

Posted on 2006-10-31
1
208 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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 count occurrences of each item in an array.

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now