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 )
Â
⇒Understanding PHP Arrays and Their Basic Operations
⇒⇒PHP Tutorials
2017-01-29, 1406👍, 0💬
Popular Posts:
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How to include additional claims in Azure AD v2.0 id_tokens? If you want to include additional claim...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
How to access Request body from "context.Request.Body" object in Azure API Policy? Request body is t...