Solved

Restrict Textarea Input

Posted on 2006-10-31
1
207 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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encode a password 2 36
Wordpress Query 1 30
get radio button vale in array 7 35
PHP string issue 5 16
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

771 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

12 Experts available now in Live!

Get 1:1 Help Now