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, 2046🔥, 0💬
Popular Posts:
FYIcenter JSON Validator and Formatter is an online tool that checks for syntax errors of JSON text ...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How to start Docker Daemon, "dockerd", on CentOS systems? If you have installed Docker on your CentO...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...