Answer the question
In order to leave comments, you need to log in
What am I doing wrong with file_get_contents?
<?php
$str=file_get_contents('*******page=1');
preg_match_all('#<a class="item last" href="/rus/list/avtoservis\?page=(.+?)#su', $str, $pages);
dd($pages);
<a class="item last" href="/rus/list/avtoservis?page=5">последняя »</a>
array:2 [▼
0 => array:2 [▼
0 => "<a class="item last" href="/rus/list/avtoservis?page=5"
1 => "<a class="item last" href="/rus/list/avtoservis?page=5"
]
1 => array:2 [▼
0 => "5"
1 => "5"
]
]
Answer the question
In order to leave comments, you need to log in
There are probably two pagination blocks on the page that match the specified regular expression.
By default, the PREG_PATTERN_ORDER flag is passed to preg_match_all
PREG_PATTERN_ORDER Orders
the results so that the $matches[0] element contains an array of full pattern occurrences, the $matches[1] element contains an array of occurrences of the first subpattern, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question