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, ∼3122🔥, 0💬
Popular Posts:
What are the differences of Differences of evaluateTransaction() and submitTransaction() of the fabr...
How to use the "set-body" Policy Statement for an Azure API service operation? The "set-body" Policy...
What Is session_register() in PHP? session_register() is old function that registers global variable...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How to create a VC# class and build it into a library? If you want to create a VC# class and build i...