I am trying to create an array from input in a textarea.
I have a file named with a textarea.The textarea might contain values like(exactly the way it looks):
CREATE this.
DO that.
STOP it.
Basically,I want to use PHP to :
Create an array out of the values given by the textarea for example,the array madefrom th values of the textarea above is meant to be :
Array
(
[0] => create this
[1] => do this
[2] => Stop it
)
I'v e tried the following code:
<?php
$wholecode=$_POST['code'];
$code=explode('.',trim(strtolower($wholecode)));//convert code to array
$words=explode(' ', $code);
print_r($code);
I get
Array
(
[0] => create this
[1] =>
do this
[2] =>
stop it
[3] =>
)
As it clearly shows,that is not what I want.Please help
$code=explode('.'.PHP_EOL,trim(strtolower($wholecode)));try with this part ?'.PHP_EOL'is the literal text.PHP_EOL... constants do not get replaced in single or double quoted strings, you need to use string concatenation in this place:'.'.PHP_EOL