Tools, FAQ, Tutorials:
Looping through an Array without "foreach" in PHP
How To Loop through an Array without Using "foreach" in PHP?
✍: FYIcenter.com
PHP offers the following functions to allow you loop through an array without using the "foreach" statement:
Here is a PHP script on how to loop through an array without using "foreach":
<?php
$array = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java");
print("Loop with each():\n");
reset($array);
while (list($key, $value) = each($array)) {
print("[$key] => $value\n");
}
print("\n");
print("Loop with current():\n");
reset($array);
while ($value = current($array)) {
print("$value\n");
next($array);
}
print("\n");
?>
This script will print:
Loop with each(): [Zero] => PHP [One] => Perl [Two] => Java Loop with current(): PHP Perl Java
⇒ Creating an Array with a Sequence in PHP
⇐ Randomly Retrieving Array Values in PHP
2017-01-05, ∼8613🔥, 0💬
Popular Posts:
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
What is Fabric CA (Certificate Authority)? Fabric CA (Certificate Authority) is a component of Hyper...