?
Solved

probably an easy php array question

Posted on 2006-06-30
3
Medium Priority
?
248 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 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">
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

809 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