php - how to compare values in array in while loop -


my while loop condition looks this:

while ($currentmodif <= $lastmodif)  { .....thing done } 

now instead of comparing between 2 values, compare between array , string.

the array this:

array(2) {   [0]=>   array(2) {     ["time"]=>     int(1473735528)     ["id"]=>     string(1) "3"   }   [1]=>   array(2) {     ["time"]=>     int(1473507326)     ["id"]=>     string(1) "4"   } } 

and

$lastmodif = 1473503210; 

so how compare if value of key called time in given array greater $lastmodif in while loop?

to expand on @siddhesh's comment, foreach loop through array fine.

foreach($yourarray $item) {   if($item['time'] <= $lastmodif) {      // work   } } 

this loop goes through array , giving copy of each item. if want modify items, need use reference:

foreach($yourarray &$item) {      // <-- notice &   if($item['time'] <= $lastmodif) {     // work   } } 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -