Welcome to WebmasterWorld Guest from 18.210.22.132

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Textarea Tag & PHP

     
1:43 pm on Dec 27, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:May 5, 2004
posts:59
votes: 0


Hi all,

I have a simple script which takes a variable sent from a form, and then displays it a few times, in different variations (I use this script for generating Adwords keywords, so if I input the keyword widget, I will get "widget", [widget], etc.

What I want to do is have a Textarea tag instead of text input tag, so I have the ability to put a list of keywords, one on each line, and then the script will output each of the keywords in its variations.

I guess it should be simple, but considering my PHP experience... well, I'll be happy to get some help on this.

By the way, I tried to change the text input to text area but when I type a few lines of keywords, the script treats them like they were one long keyword.

Happy Holidays & Thanks in advance for your help..!

2:18 pm on Dec 27, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 26, 2003
posts:1133
votes: 0


So you need the php to process the lines indepedently?

<form name="a" method="POST" action="index.php">
<textarea name="search"></textarea></form>

<?php
$text = str_replace("\r", "", $_POST['search']);//to process the windows new line
$arrtext = explode("\n", $text);// create array of keywords
foreach($arrtext as $keyword)
{
echo "Keyword is: $keyword<br />";//process the keywords as you like
}

Hope this helps you
Regards
Michal

PS. If you want to input default value into textarea with php:
<textarea name="search"><?php echo $default;?></textarea>

2:30 pm on Dec 27, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:May 5, 2004
posts:59
votes: 0


Thank you so much - it works perfectly..!

Take care,
emoshe