php - Assigning values to variable on the fly in WHILE loop condition -


i've piece of code

$limit = 100; $offset = 0;  while (array() === ($contactidlist = $this->getdata($limit, $offset))) {     $count = count($contactidlist);     //using $count , $contactidlist doing logging stuff       $offset += $limit; } 

$this->getdata($offset) //returns array of results query in set $limit, $offset when results been fetched returns empty array , while conditions end.

my question i'm assigning array results in $contactidlist in while condition save 1 line $contactidlist = $this->getdata($limit, $offset) inside while condition. right way?

this looks fine me. 1 suggestion, can use empty() if using php 5.5.0 , later check empty array

$limit = 100; $offset = 0;  while(!empty($contactidlist = $this->getdata($limit, $offset))) {     $count = count($contactidlist);     //using $count , $contactidlist doing logging stuff       $offset += $limit; } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -