D
D
dimaweyder2019-07-29 12:31:23
PHP
dimaweyder, 2019-07-29 12:31:23

How to calculate the number of li?

5d3ebd02275b1357970536.jpeg

$images = $pw->find('ul.lory-slider__list li');
      $f = count($images);

This code only counts the 4 li's that are visible in the slider.
How can I count ALL li?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pdbqman, 2019-07-30
@pdbqman

You need the simple_html_dom.php library
1. curl to your page
2. use foreach to find the required ul list and count in it.
maybe there will be more than one foreach (depending on how difficult it is to get to the desired ul)
here is my piece of shit code as an example

$this->simple_html_dom( curl_exec($this->curl) );
$table = $this->result->find('table table', 2); // ******* Здесь таблица c Идентификаторами файлов (статус отчета)
$this->simple_html_dom( $table );
      
foreach($table->find('tr') as $key => $tr) {
  if( $key < 7 ){
    // Ищу ссылки, что бы их подменить и сделать валидными путем добавления
    foreach($tr->find('a') as $a_href) {
      //echo $a_href->href."</br>"; 
      $a_href->href = "http://xxx.ru".$a_href->href; // Замена ссылки
    }
    $buf_table = $buf_table . $tr->outertext;
  }
}
// Делаю это здесь т.к. по нормальному пока не получилось
$buf_table = str_replace("href", "target='_blank' href", $buf_table);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question