Solved

probably an easy php array question

Posted on 2006-06-30
3
239 Views
Last Modified: 2006-11-18
How do I get the text line by line from a textarea box an put it into an array?
0
Comment
Question by:ray-solomon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Autogard earned 250 total points
ID: 17021960
You need to create the form on the first page that posts to a second page.

-- First Page --
<form method="post" action="otherpage.php">
<textarea name="mytext">
Hello!
</textarea>
<input type="submit" name="submitform" />

-- Next Page --
<?php

    $textFromBox = $_POST["mytext"];
   
    # Now it just depends on how you want to split up the text -- I'll do it line by line
    $myArray = explode("\r\n", $textFromBox);

?>

You could also submit to the same page, you would just need to check that there is a value in $_POST["mytext"].
0
 
LVL 10

Author Comment

by:ray-solomon
ID: 17021975
Thanks for the quick reply..it works
0
 
LVL 8

Expert Comment

by:Autogard
ID: 17021979
Awesome!  One thing, I forgot to close the </form> on the first page.
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

696 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