Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Loop through an Array without Using "foreach"
How To Loop through an Array without Using "foreach"? - PHP Script Tips - PHP Built-in Functions for Arrays
✍: 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
2007-04-14, 5264👍, 0💬
Popular Posts:
How To Merge Cells in a Row? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells If you wan...
How To Enter Numeric Values as HEX Numbers? - MySQL FAQs - Introduction to SQL Basics If you want to...
How can I execute a PHP script using command line? Just run the PHP CLI (Command Line Interface) pro...
How can I check for HTML errors? HTML validators check HTML documents against a formal definition of...
How To Control Table Widths? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells Usually, b...