I tried to write a php code that would read a text file, convert it into a multidimensional array.
My text looks like:
Random Header 1
1. List item 1
2. List item 2
3. List item 3
...........
...........
Random Header Title 2
1. List item 1
2. List item 2
3. List item 3
...........
...........
and the random header and lists
And now, I want to convert the above text into array that looks,
Array
(
[Random Header 1] => Array
(
[0] => "1. List item 1",
[1] => "2. List item 2",
[2] => "3. List item 3"
),
[Random Header Title 2] => Array
(
[0] => "1. List item 1",
[1] => "2. List item 2",
[2] => "3. List item 3"
)
)
Notice that the headers begins with a string, and list items start with number.
I used php's file() function to read, I have a hard time converting into the way I wanted.
Solution please!!it's not working like that. First, show us what have you tried so far.file()function