Solved

probably an easy php array question

Posted on 2006-06-30
3
230 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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

679 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