Tools, FAQ, Tutorials:
Order of Array Values in PHP
How the Values Are Ordered in an Array in PHP?
✍: FYIcenter.com
PHP says that an array is an ordered map. But how the values are ordered in an array? The answer is simple. Values are stored in the same order as they are inserted like a queue. If you want to reorder them differently, you need to use a sort function. Here is a PHP script show you the order of array values:
<?php
$mixed = array();
$mixed["Two"] = "Java";
$mixed["3"] = "C+";
$mixed["Zero"] = "PHP";
$mixed[1] = "Perl";
$mixed[""] = "Basic";
$mixed[] = "Pascal";
$mixed[] = "FORTRAN";
$mixed["Two"] = "";
unset($mixed[4]);
print("Order of array values:\n");
print_r($mixed);
?>
This script will print:
Order of array values:
Array
(
[Two] =>
[3] => C+
[Zero] => PHP
[1] => Perl
[] => Basic
[5] => FORTRAN
)
⇒ Copying Array Values to a List of Variables in PHP
⇐ Looping through an Array in PHP
2017-01-29, ∼2375🔥, 0💬
Popular Posts:
How to use "link" command tool to link objet files? If you have object files previously compiled by ...
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...
How to login to the Developer Portal internally by you as the publisher? Normally, the Developer Por...
Can Two Forms Be Nested? Can two forms be nested? The answer is no and yes: No. You can not nest two...
How to Install Docker Desktop 2.5.0 on Windows 10? You can follow this tutorial to Install Docker De...