Tools, FAQ, Tutorials:
Creating an Array in PHP
How To Create an Array in PHP?
✍: FYIcenter.com
You can create an array using the array() constructor. When calling array(), you can also initialize the array with pairs of keys and values. Here is a PHP script on how to use array():
<?php print("Empty array:\n"); $emptyArray = array(); print_r($emptyArray); print("\n"); print("Array with default keys:\n"); $indexedArray = array("PHP", "Perl", "Java"); print_r($indexedArray); print("\n"); print("Array with specified keys:\n"); $mappedArray = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java"); print_r($mappedArray); print("\n"); ?>
This script will print:
Empty array: Array ( ) Array with default keys: Array ( [0] => PHP [1] => Perl [2] => Java ) Array with specified keys: Array ( [Zero] => PHP [One] => Perl [Two] => Java )
⇒ Testing If a Variable Is an Array in PHP
2016-10-15, 1573🔥, 0💬
Popular Posts:
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
What is EPUB 2.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 2.0 Metadata "dc:publisher" ...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
How to start Docker Daemon, "dockerd", on CentOS systems? If you have installed Docker on your CentO...
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...