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, ∼7511🔥, 0💬
Popular Posts:
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...
Where can I download the EPUB 2.0 sample book "The Metamorphosis" by Franz Kafka? You can following ...
FYIcenter.com Online Tools: FYIcenter JSON Validator and Formatter FYIcenter JSON to XML Converter F...
How to use the "@(...)" expression in Azure API Policy? The "@(...)" expression in Azure API Policy ...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...