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, 7192🔥, 0💬
Popular Posts:
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...
How to build a test service operation to dump everything from the "context.Request" object in the re...
Where to find tutorials on PHP language? I want to know how to learn PHP. Here is a large collection...
How to detect errors occurred in the json_decode() call? You can use the following two functions to ...