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, 2536👍, 0💬
Popular Posts:
Where Is the Submitted Form Data Stored in PHP? When a user submit a form on your Web server, user e...
Where to find tutorials on Using Azure API Management Publisher Dashboard? Here is a list of tutoria...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...