I am trying to identify dates in some strings and the day of week and put the data into another array. My problem is that the data comes in array but not in a regular order.
Example #1 of data structure:
Array (
[3] => In ziua de Duminica 26.10.2014 Duminica 27.10.2013 // note both of dates in the same line
[4] => Consum de energie electrica
[5] => Mediu 6168 5407
[6] => Maxim 7233 6552
)
Example #2 of data structure:
Array (
[3] => In ziua de Miercuri 15.10.2014 // note first line contains few more words
[4] => Miercuri 16.10.2013
[5] => Consum de energie electrica
[6] => Mediu 6573 6747
[7] => Maxim 7771 7892
)
Example #3 of data structure:
Array (
[4] => Marti 14.10.2014
[6] => Marti 15.10.2013
[7] => Consum de energie electrica
[8] => Mediu 6453 6754
[9] => Maxim 7551 7860
)
Example #4 of data structure:
Array (
[4] => Duminica 04.05.2014
[6] => Duminica // note the line with only day of week and next line is the date
[7] => 05.05.2013
[8] => Consum de energie electrica
[9] => Mediu 5265 4262
[10] => Maxim 6318 4873
)
Example #5 of data structure:
Array (
[4] => Miercuri12.02.2014 // note the missing space between the day of week and date
[6] => Miercuri 13.02.2013
[7] => Consum de energie electrica
[8] => Mediu 7274 7434
[9] => Maxim 8313 8401
)
All of these structures are repetitive. I try to find a way to collect the lines for Mediu XXXX XXXX
and Maxim XXXX XXXX
.
I want to create an array that should be look like this
(let's take example #1):
Array (
[0] => Array (
[weekday] => Duminica
[date] => 26.10.2014
[Mediu] => 6168 // first value from line
[Maxim] => 7233 // first value from line
)
[1] => Array (
[weekday] => Duminica
[date] => 27.10.2013
[Mediu] => 5407 // second value from line
[Maxim] => 6552 // second value from line
)
)
Is there a possibility to achieve this? I don't have any regex idea to split data.
Thank you.