-3

To get the li values in this code; I m use to curl with php. After Html has too many ul. So I have to put selector class name.

 <ul class="pagination ng-scope">
    <li class="arrow previous unavailable"><a href="#listable"><i></i></a></li>
    <li class="current"><a href="http://blablaa.com/1">1</a></li>
    <li><a href="http://blablaa.com/2">2</a></li>
    <li class="arrow next"><a href="http://blablaa/2#listable" class="next"><i></i></a></li>
</ul>


preg_match('#<ul class="pagination">(.*?)</ul>#msi', $result['result'], $pagination);
print_r($pagination);
preg_match_all('#<li>.*?</li>#msi', $pagination[1], $pages);

for ($i = 1; $i <= count($pages[0]) + 1; $i++) {
    $link = $baselink . "/" . $i;
}

echo $link;

but not result.Please help me, thanks.

bado57
  • 1
  • 1

1 Answers1

0

You start you regular expression with

<ul class="pagination">

and your HTML starts with

<ul class="pagination ng-scope">

which is clearly not a match for the expression. Change <ul class="pagination"> to <ul class="pagination.*"> to start getting matches.


If you want the page numbers, you can use '#<a[^>]*>(\d+)</a>#msi' regex, which collects all the numbers within an <a> tag. example

Laposhasú Acsa
  • 1,550
  • 17
  • 18