This article introduces several useful array functions in PHP4 to reproduce the associative array equivalent to the hash array in Perl. I used to think that PHP didn't ... _php tutorial

Source: Internet
Author: User
Describes several PHP4 "array" functions that are useful in 1 void extract (array var_array [, int extract_type] [, string prefix]]) to expand an associative array to the value of the variable name and variable, and if there is a conflict, the The following parameters specify the processing Method! Such as:
"Blue", "size" = "medium", "shape" = "sphere"); Extract ($var _array, Extr_prefix_same, "WDDX"); Print "$color, $size, $shape, $wddx _sizen";?> 2 Array compact (mixed varname [, mixed ...]) In contrast to the above function, save the variable name and the value of the variable in the associative array Surface! such as: $city = "San Francisco"; $state = "CA"; $event = "SIGGRAPH"; $location _vars = Array ("City", "state"); $result = Compact ("event", "Nothing_here", $location _vars); The $result result is an array ("event" = "SIGGRAPH", "City" = "San Francisco", "state" and "CA"). 3 bool In_array (mixed needle, array haystack) determine if there is a value in the array 4 void Natsort (array array) to sort the array by natural number, at which point 12 will be ranked after 2 $array 1 = $array 2 = Array ("Img12.png", "Img10.png", "Img2.png", "img1.png"); Sort ($array 1); echo "standard sort n"; Print_r ($array 1); Natsort ($array 2); echo "N natural sort N"; Print_r ($array 2); The code output is: Standard sort array ([0] = img1.png [1] = img10.png [2] = img12.png [3] = img2.png) Natural sort Array ([3] = = img1.png [2] = img2.png [1] = img10.png [0] = img12.png)

http://www.bkjia.com/PHPjc/531781.html www.bkjia.com true http://www.bkjia.com/PHPjc/531781.html techarticle describes several php4 useful array functions 1 void Extract (array var_array [, int extract_type] [, string prefix]]) to expand an associative array into the value of a variable name and variable, such as ... /c5>

  • Related Article

    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.