J
J
jistulamle2017-10-04 08:22:09
PHP
jistulamle, 2017-10-04 08:22:09

Doesn't display the entire result of the cycle (PHP), why?

There is a loop looking for links to pages, but according to the criteria, the listing is below

function web_post($ind = null, $params = null){

  $content = post_get('http://habrahabr.ru');

  preg_match_all('/<div class="web_http(.*?)\>/s', $content, $url);
  $x = '1';

  while($x <= $ind){

    preg_match('/data-type="(.*?)\_/', $url[1][$x], $url_k);

    if($params == 1){

      if($type[1]=='poster'){

        preg_match('/ poster(.*?)\"/', $url[1][$x], $url_one);
        $result = $url_one[1];
        $x++;
        
      }
    }else{

      preg_match('/ web(.*?)\"/', $url[1][$x], $url_two);
      $result = $url_two[1];
      $x++;

    }

  echo result;

  }
}

web_post(5, 1);

There are two types of parameter 1 and 0, when parameter 1 is specified in the web_post function, the page is loaded for a long time and nothing is displayed, with parameter 0 this is not the case, everything is displayed quickly. Why is there an error?
Ideally, 5 results should be output with satisfactory conditions.
PS If you need to explain something, tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-10-04
@jistulamle

when specifying parameter 1 in the web_post function, the page is loaded for a long time

Because the condition does not pass if ($type[1]=='poster'), $xdoes not increase, and everything goes in cycles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question