Answer the question
In order to leave comments, you need to log in
PHP. preg_match_all how to do nested parsing?
Greetings. I'm new to RNR. I'm learning. I want to make a text parser with a record in the database according to the conditions. I figured out the principle of the function, but I just can’t move further, here’s where:
INTRODUCTION INFO:
There is the following text: (input was made by POST c TEXTAREA )
Yanitic:ачив не найдено
yurahm: медаль золото(23:10 12-12-2014)
59д Жертвам Голодомору(T2617, Voronovytsya, Chernivets' ka oblast, Ukraine) https://www.ingress.com/intel?ll=48.530544,26.64706&z=17&pll=48.530544,26.64706
59д Памятник Неизвестного Солдату (Unnamed Road, Sokil, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=48.529953,26.645298&z=17&pll=48.529953,26.645298
58д Капличка(Unnamed Road, Ruda, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=48.555892,26.567197&z=17&pll=48.555892,26.567197
39д Олень(E50, Vinnyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.366811,27.984859&z=17&pll=49.366811,27.984859
39д Сержант Петренко(E50, Vinnyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.366651,27.985773&z=17&pll=49.366651,27.985773
32д Собор Святого Михаїла(Olimpiiska St, Khmelnytskyi, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.435902,26.958889&z=17&pll=49.435902,26.958889
15д Стадиончик(Lyali Ratushnoi Street, 128, Vinnytsia, Vinnyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.221695,28.433667&z=17&pll=49.221695,28.433667
zZHunteRZz:ачив не найдено
zZWehrZz:ачив не найдено
GhostPathfinder: медаль золото(03:19 19-02-2016)
54д памятник Володарскому(Н03, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.806018,27.56081&z=17&pll=49.806018,27.56081
54д церковь(Н03, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.806456,27.561546&z=17&pll=49.806456,27.561546
54д Павшим В Боях(Н03, Krasnoselka, Zhytomyrs' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.989098,28.000007&z=17&pll=49.989098,28.000007
54д Часовня на перекрёстке(E101, Chernihivs' ka oblast, Ukraine) https://www.ingress.com/intel?ll=51.139195,31.862377&z=17&pll=51.139195,31.862377
54д Прокопович Петр Иванович(E101, Chernihivs' ka oblast, Ukraine) https://www.ingress.com/intel?ll=51.298025,32.770144&z=17&pll=51.298025,32.770144
1д Filarmoniya(Haharina street, 5, Khmelnytskyi, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.418876,26.976199&z=17&pll=49.418876,26.976199
Answer the question
In order to leave comments, you need to log in
I would pervert like this:
Line by line looking for the presence of " https://www.ingress.com/intel " in the line.
If it is not found, then from this line we parse the achievement with the date or "achievement not found"
from all subsequent lines in which " https://www.ingress.com/intel " is found We take the list of portals assigned to the last found user into the database .
for($i=0;$i<count($list);$i++){
if(stristr($list[$i], 'https://www.ingress.com/intel') === FALSE) {
$login = 'парсим логин с $list[$i] и присваеваем';
} else {
$port = 'парсим данные портала и прочее с $list[$i]';
}
Кладём в БД $login $port;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question