Tutorial :How do I write this foreach loop as any other kind of loop?



Question:

foreach ($a as $b)  {  do function  }  


Solution:1

while ($b.MoveNext())  {      $a = $b.Current;  }  


Solution:2

reset($a);  while (list($key, $value) = each($a)) {     //...  }    $keys = array_keys($a);  while (($key = array_shift($keys)) !== NULL))  {    $b = $a[$key];  }  


Solution:3

$i = 0;  while ($i < count($a))  {    $b = $a[$i];      //do function      $i++;  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »