PHP multi-dimensional array Key value use

Source: Internet
Author: User

<?PHP$user["60"] =Array("id" and "max", "num" = "+", "Count" and "31");$user["61"] =Array("id" = "+", "num" and "+", "Count" and "34");$user["59"] =Array("id" = "i", "num" = "+", "Count" and "43");$user["56"] =Array("id" = "+", "num" and "$", "count" and "38");$user["57"] =Array("id" and "+", "num" and "All", "count" and "65");$values=array_values($user);//returns all values of an array (non-key names)$keys=Array_keys($user);//returns a new array containing all the key names in the array$iskey=array_key_exists("57",$user);//checks whether the specified key name exists in an array, returns true if the key name exists, or False if the key name does not exist. $iskey=array_key_exists(57,$user);//As a result, the type is not dependent, and the number 57 is the same as the string "57". $key=Array_keys($keys, 57);//the function returns a new array that contains all the key names in the array. If the second argument is supplied, only the key name of the value is returned. $result[' status '] = 0;$result[' Res ']=Count($key);// $result [' res '] = $user;//-----------return value is object://-----------{"status": 0, "res": {"60": {" ID ":" "num": "+", "Count": "+"}, "Max": {"id": "max", "num": "$", "Count": "" "}," "": "" id ":" the "," num ":" + "," Count ": "" "}," "": {"id": "$", "num": "", "" Count ":" ""}, "" ":" id ":" "", "num": "" "," Count ":" $ "}}}//$result [' res '] = $ values;//-----------return value is an array://-----------{"status": 0, "res": [{"id": "$", "num": "$", "Count": "},{" "id": "max", "num ":", "Count": "},{", "num": "", "" "," "" "," "Count": "},{" "id": "" "," num ":" "", "Count": "},{" "id": "page", "num": "Max", "Count": "}]}//" $result [' res '] = $keys;//-----------The return value is a one-dimensional array of key://-----------{"status": 0, "res": [ 60,61,59,56,57]}//sort ($user);//After the key is sorted, key is filtered out//$result [' res '] = $user;//-----------The return value is a multidimensional array sorted by key (not including key):// -----------{"status": 0, "res": [{"id": "},{", "num": "$", "Count": "$", "id": "$", "num": "$", "Count": "},{", "id": " "num": "+", "Count": "},{" "id": "$", "num": "+", "Count": "},{" id ":", "num": "$", "Count": "The"}]} EchoJson_encode ($result);?>

PHP multi-dimensional array Key value use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.