Solved

probably an easy php array question

Posted on 2006-06-30
3
198 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
Comment Utility
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
Comment Utility
Thanks for the quick reply..it works
0
 
LVL 8

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
htacces issue 2 37
Link SQL table to Webpage 9 34
resizeing PHP image 2 21
Creating a slider 12 32
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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

11 Experts available now in Live!

Get 1:1 Help Now