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
How to Loop through an Array? - PHP Script Tips - Understanding PHP Arrays and Their Basic Operations
✍: FYIcenter.com
The best way to loop through an array is to use the "foreach" statement. There are two forms of "foreach" statements:
Here is a PHP script on how to use "foreach" on an array:
<?php $array = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java"); $array["3"] = "C+"; $array[""] = "Basic"; $array[] = "Pascal"; $array[] = "FORTRAN"; print("Loop on value only:\n"); foreach ($array as $value) { print("$value, "); } print("\n\n"); print("Loop on key and value:\n"); foreach ($array as $key=>$value) { print("[$key] => $value\n"); } ?>
This script will print:
Loop on value only: PHP, Perl, Java, C+, Basic, Pascal, FORTRAN, Loop on key and value: [Zero] => PHP [One] => Perl [Two] => Java [3] => C+ [] => Basic [4] => Pascal [5] => FORTRAN
2007-04-20, 5054👍, 0💬
Popular Posts:
What Is URI? URI (Uniform Resource Identifier) is a superset of URL. URI provides a simple and exten...
How To Get the Uploaded File Information in the Receiving PHP Script? Once the Web server received t...
How do we host a WCF service in IIS? Note: - The best to know how to host a WCF in IIS is by doing a...
How do you estimate maintenance project and change requests?
What is the difference between "printf(...)" and "sprintf(...)"? sprintf(...) writes data to the cha...