Page 1 of 1

Need help with arrays in php

Posted: Thu Jun 11, 2009 10:33 pm
by cool30
I have a textbox -"textfield0" on a form. The user can enter as many phrases as he/she wants.The text in each line is a phrase.
There is another textbox-"textarea2" which should display each phrase which is entered in textfield0 to a new line in textarea2.(Each line should be copied as is)I am trying to use array here but the code isn't working. If someone can point out what am I doing wrong and how can I correct it.

Code: Select all

 
$phrase = array('textfield0');
foreach($phrase as $val)
{
  print"$val<BR>";
// this code doesn't work
}
 
 
 
Thanks

Re: Need help with arrays in php

Posted: Thu Jun 11, 2009 11:47 pm
by Benjamin

Code: Select all

$phrases = array_map('trim', explode("\n", $_POST['textfield0']));

Re: Need help with arrays in php

Posted: Fri Jun 12, 2009 1:21 pm
by cool30
Thanks