介绍几个php4中非常有用的数组函数转载关联数组等同于PERL里的哈希数组。以前我一直以为PHP里没...
介绍几个 php4 中非常有用的"数组"函数 1 void extract (array var_array [, int extract_type ][, string prefix]]) 把一个关联数组展开为变量名和变量的值,如果有冲突则由后面的参数指定处理方法! 如:
"blue", "size" => "medium", "shape" => "sphere"); extract ($var_array, EXTR_PREFIX_SAME, "wddx"); print "$color, $size, $shape, $wddx_sizen"; ?> 2 array compact (mixed varname [, mixed ...]) 和上面的函数相反,把变量名和变量的值保存到关联数组里面! 如: $city = "San Francisco"; $state = "CA"; $event = "SIGGRAPH"; $location_vars = array ("city", "state"); $result = compact ("event", "nothing_here", $location_vars); $result 结果为 array ("event" => "SIGGRAPH", "city" => "San Francisco", "state" => "CA"). 3 bool in_array (mixed needle, array haystack) 判断数组中是否有这个值 4 void natsort (array array) 以自然数的方法排序数组,这时 12 将排在2的后面 $array1 = $array2 = array ("img12.png","img10.png","img2.png","img1.png"); sort($array1); echo "标准排序n"; print_r($array1); natsort($array2); echo "n自然排序n"; print_r($array2); 代码输出为: 标准排序 Array ( [0] => img1.png [1] => img10.png [2] => img12.png [3] => img2.png ) 自然排序 Array ( [3] => img1.png [2] => img2.png [1] => img10.png [0] => img12.png )

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)