Solved

Restrict Textarea Input

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

861 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