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
2017-01-05, 1395👍, 0💬
Popular Posts:
Where to find tutorials on OpenID? Here is a large collection of tutorials to answer many frequently...
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...
What properties and functions are supported on http.client.HTTPResponse objects? If you get an http....
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...