0
I have a textarea that takes data like the following (example):
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
How can I transform each line of this textarea into an array with keys, in an organized way and taking out the "0" before the numbers (01, 02, 03 [...])?
I tried to get array_values(array_filter(explode(PHP_EOL, $_POST['textarea'])))
but I’m getting a result like the following:
array (size=5)
0 => string '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' (length=59)
1 => string '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' (length=59)
2 => string '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' (length=59)
3 => string '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' (length=59)
4 => string '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' (length=59)
That way there are no keys that match each number.
The expected return would be something like this:
var_dump($array[0])
array (size=20)
0 => string '1' (length=1)
1 => string '2' (length=1)
2 => string '3' (length=1)
3 => string '4' (length=1)
4 => string '5' (length=1)
5 => string '6' (length=1)
6 => string '7' (length=1)
7 => string '8' (length=1)
8 => string '9' (length=1)
9 => string '10' (length=2)
10 => string '11' (length=2)
11 => string '12' (length=2)
12 => string '13' (length=2)
13 => string '14' (length=2)
14 => string '15' (length=2)
15 => string '16' (length=2)
16 => string '17' (length=2)
17 => string '18' (length=2)
18 => string '19' (length=2)
19 => string '20' (length=2)
This for each line of the textarea.
What is the desired output? You can put an example?
– Woss
I edited the question, Anderson.
– Thiago