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, 5138👍, 0💬
Popular Posts:
What are the core functionalities in XML .NET framework? Can you explain in detail those functionali...
How Can we change priority & what levels of priority are provided by Dot Net? Thread Priority ca...
How To Create an Add-to-NewsGator Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News...
What is test metrics? Test metrics accomplish in analyzing the current level of maturity in testing ...
How To Control White Spaces between Table Cells? - XHTML 1.0 Tutorials - Understanding Tables and Ta...