probably an easy php array question

Posted on 2006-06-30
Medium Priority
Last Modified: 2006-11-18
How do I get the text line by line from a textarea box an put it into an array?
Question by:ray-solomon
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

Accepted Solution

Autogard earned 1000 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">
<input type="submit" name="submitform" />

-- Next Page --

    $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"].
LVL 10

Author Comment

ID: 17021975
Thanks for the quick reply..it works

Expert Comment

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

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 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