ÏÂÃæ¾ÙÁ˼¸¸öʵÀýÖ÷ÒªÊǽ²¹ØÓÚÊä³öÊý×éËùÓеÄÖµ array_values ,Ñ»·Êä³öÊý×éµÄ¼ü/Öµ¶Ô²¢Òƶ¯Ö¸Õë reset,½«Êý×éµßµ¹£¬²»±£Áô¼üÃûarray_reverseº¯Êý²Ù×÷¡£
ÏÂÃæ¾ÙÁ˼¸¸öʵÀýÖ÷ÒªÊǽ²¹ØÓÚÊä³öÊý×éËùÓеÄÖµ array_values ,Ñ»·Êä³öÊý×éµÄ¼ü/Öµ¶Ô²¢Òƶ¯Ö¸Õë reset,½«Êý×éµßµ¹£¬²»±£Áô¼üÃûarray_reverseº¯Êý²Ù×÷¡£
*/
$array=array("size"=>"xl","color"=>"gold"); //¶¨ÒåÒ»¸öÊý×é
print_r(array_values($array)); //Êä³öÊý×éËùÓеÄÖµ
/*
¶¨ÒåºÍÓ÷¨
array_values() º¯Êý·µ»ØÒ»¸ö°üº¬¸ø¶¨Êý×éÖÐËùÓмüÖµµÄÊý×飬µ«²»±£Áô¼üÃû¡£
Óï·¨
array_values(array)
*/
$fruit=array('a'=>'apple','b'=>'banana','c'=>'cranberry'); //¶¨ÒåÒ»¸öÊý×é
reset($fruit); //Ö¸ÕëÒÆ¶¯µÚÒ»¸öλÖÃ
while(list($key,$val)=each($fruit)) //Ñ»·Êä³öÊý×éµÄ¼ü/Öµ¶Ô²¢Òƶ¯Ö¸Õë
{
echo "$key=>$valn"; //Êä³öÊý×éµÄ¼ü¼°Öµ
}
/*
*/
$input=array("php½Ì³Ì",3.0,array("green","red")); //¶¨ÒåÒ»¸öÊý×é
$result=array_reverse($input); //½«Êý×éµßµ¹£¬²»±£Áô¼üÃû
$result_keyed=array_reverse($input,true); //½«Êý×éµßµ¹£¬±£Áô¼üÃû
print_r($result); //ÏÔʾµÚÒ»ÖÖ½á¹û
print_r($result_keyed); //ÏÔʾµÚ¶þÖÖ½á¹û
/*
¶¨ÒåºÍÓ÷¨
array_reverse() º¯Êý½«ÔÊý×éÖеÄÔªËØË³Ðò·×ª£¬´´½¨ÐµÄÊý×é²¢·µ»Ø¡£Èç¹ûµÚ¶þ¸ö²ÎÊýÖ¸¶¨Îª true£¬ÔòÔªËØµÄ¼üÃû±£³Ö²»±ä£¬·ñÔò¼üÃû½«¶ªÊ§¡£
Óï·¨
array_reverse(array,preserve)
*/
$array=array(0=>100,"color"=>"red"); //¶¨ÒåÒ»¸öÊý×é
print_r(array_keys($array)); //·µ»Ø¸ÃÊý×éµÄËùÓмüÃû
$array=array("blue","red","green","blue","blue"); //¶¨ÒåÒ»¸öÊý×é
print_r(array_keys($array,"blue")); //·µ»ØÖµÎªblueµÄ¼üÃû
//¶¨ÒåÒ»¸öÔªËØÎªÊý×éµÄÊý×é
$array=array("color"=>array("blue","red","green"),"size"=>array("small","medium","large"));
print_r(array_keys($array)); //·µ»ØÊý×éµÄËùÓмüÃû
/*
¶¨ÒåºÍÓ÷¨
array_keys() º¯Êý·µ»Ø°üº¬Êý×éÖÐËùÓмüÃûµÄÒ»¸öÐÂÊý×é¡£
Èç¹ûÌṩÁ˵ڶþ¸ö²ÎÊý£¬ÔòÖ»·µ»Ø¼üֵΪ¸ÃÖµµÄ¼üÃû¡£
Èç¹û strict ²ÎÊýÖ¸¶¨Îª true£¬Ôò php »áʹÓÃÈ«µÈ±È½Ï (===) À´Ñϸñ¼ì²é¼üÖµµÄÊý¾ÝÀàÐÍ¡£
Óï·¨
array_keys(array,value)

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use

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