PHP Êý×éÈëÃŽ̳ÌС½á

5年以前  |  阅读数:505 次  |  编程语言:PHP 

Õaô¶aµÄÊý×eº¯ÊýÎÒÃǸÃÔoôѧϰ£¿ÆaʵÎÒÃÇÖ»ÐeÒªÇa³þ£¬ÎÒÃÇÐeÒª¶ÔÊý×e×oÄÄÐ(C)²Ù×÷£¬È»ºo°ÑÕaÐ(C)²Ù×÷¹eÀa£¬ÐÄÖоÍÓÐÁË´o¸ÅµÄÓ¡Ïo£¬È»ºoËae×ÅÄaµÄʵ¼u£¬ÕaÐ(C)º¯ÊýÄa¾ÍºÜÇa³þÁË£¬ÔÚÕaÀiÌaÐÑ´o¼ÒµÄÊÇÊÖ²aÒª³£±¸£¡*Ï»°²»¶a˵£¬Êý×eº¯ÊýÒ»°a¹eΪÒÔϼ¸Àa£¨¿´µ½Ó¢ÎıðÅÂŶ£(C)£º
Outputting arrays
Creating arrays
Testing for an array
Locating array elements
Traversing arrays
Determining array size and element uniqueness
Sorting arrays
Merging, slicing, splicing, and dissecting arrays

Outputting arrays
print_r()
²»ÊiϤÕa¸oµÄÎҾͲ»Ïe¶a˵ÁË£¡×i»u±¾µÄº¯Êý£¬µ±È»ÒªÊa³oÊý×eÒ²¿ÉÊÇʹÓÃÑ­»½a¹¹Êa³o£¬²»¹ýÓÐÕaô½±aµÄÊa³oº¯Êý¸ÉÂð²»ÓÃÄØ£¡

Creating arrays
array()
Õa¸oº¯ÊýÎÒÒ²²»Ïe˵ÁË£¬ÕaÆaʵֻÄÜËaÓiÑÔ½a¹¹£¬´o¼ÒÔÚн¨Êý×eµÄʱºo¶¼Óõ½¹ý£¬Ã»ÓùýµÄÎÒÖ»ÄÜ˵£¬Ðֵܣ¬ÎÒÎÞÓiÁË£¡
list()
Õa¸oº¯ÊýºÍÉÏÃaeÌaµ½µÄ array()Ò»Ñu£¬Ö»ÊǸoÓiÑÔ½a¹¹£¬Ëuͨ¹ýÒ»²½²Ù×÷¸øÒ»×e±aÁ¿¸³Öµ£¡
¾ßÌaʾÀýÇe²e¿´ÊÖ²a£¡
range();
array range ( mixed low, mixed high[, number step] )
½¨Á¢Ò»¸o°uº¬Ö¸¶¨*¶Î§µ¥ÔªµÄÊý×e
ʾÀý£º $arr =range(0, 6);
Ïaµ±ÓÚ $arr =array(0, 1, 2, 3, 4, 5, 6);
Ò»°aÊý¾Ý°´´ÓµÍµ½¸ßÅÅÁУ¬Èç¹u low> high£¬Ôo´Ó¸ßµ½µÍÅÅÁУ»

Testing for an array
is_array();
²aÊÔ±aÁ¿ÊÇñarrayÀaÐÍ£¬ÊÇÔoµ»Øtrue£¬²»ÊÇÔo*µ»Øfalse£¬ºÜ»u±¾£¬ºÜʵÓõĺ¯Êý£¡

Adding and removing array elements
array_push()
int array_push ( array ⌖_array,mixed var [, mixed ...] )
½«Ò»¸o»o¶a¸oµ¥Ôª´ÓÄ(C)βÌi¼ÓÖÁÊý×e£¡*µ»ØÐÂÊý×eµÄµ¥Ôª×ÜÊý£¡
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$states =array( ¡®Ohio' , ¡®New York' );
array_push ( $states , ¡®California' , ¡®Texas' );
//output: array((¡®Ohio',¡®New York' , ¡®California',¡®Texas');

`

array_pop();
µ¯³o²¢*µ»ØÊý×eµÄ×iºoÒ»¸oµ¥Ôª£¬²¢½«Êý×e³¤¶È¼oÒ»¡£Ê¹Óúo»aÖØÖÃÊý×eÖ¸Õe£¡
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$states =array( ¡®Ohio' , ¡®New York' );
$state = array_pop ( $states );
//output: New York

`

array_shift();
Óearray_popÀaËÆ£¬Ö»²»¹ýËuÒƳoºÍ*µ»ØµÄÊÇÊý×eµÄµÚÒ»¸oÖµ¡£Êý×Ö¼uÃu½«ÖØдÓÁa¿ªÊ¼¼ÇÊý£¬ÎÄ×Ö¼uÃuÔo±£³Ö²»±a£¡

array_unshift();
Óearray_pushÀaËÆ£¬Ö»²»¹ýÊÇ´ÓÊý×eÍ*²¿²aÈeÊý¾Ý£¡Êý×Ö¼uÃu½«ÖØдÓÁa¿ªÊ¼¼ÇÊý£¬ÎÄ×Ö¼uÃuÔo±£³Ö²»±a£¡

array_pad();
array array_pad ( array input, intpad_size, mixed pad_value )
ÓÃÖµ½«Êý×eÌi³aµ½Ö¸¶¨³¤¶È!
pad_sizeΪÕý£¬Ôo´ÓÓÒ²a¿ªÊ¼Ìi²¹£¬Îª¸º£¬´Ó×o²a¿ªÊ¼Ìi²¹£¬Ð¡ÓeÊý×e³¤¶È£¬Ôo±£³ÖÊý×e²»±a£¡Ê¾Àý¼uÊÖ²a£¡

Locating array elements
in_array();
¼i²eÊý×eÖÐÊÇ*ñ´aeÔÚij¸oÖµ£¬»u´¡£¬²»ËµÁË£¬¾ßÌa¼uÊÖ²a£¡

array_keys();
array array_keys ( array input [,mixed search_value [, bool strict]] )
µ»ØÊý×eÖеÄËuÓмuÃu¡£Èç¹uÑ¡¶¨search_value£¬Ôoµ»ØÑ¡¶¨µÄ¼uÃu£¡×ÔPHP 5]Æ𣬿ÉÒÔÓÃstrict²ÎÊýÀ´½øÐÐÈ«µÈ±È½Ï£¨ ===£(C)¡£

array_key_exists();
bool array_key_exists ( mixed key,array search )
¼i²e¸ø¶¨µÄ¼uÃu»oË÷ÒýÊÇñ´aeÔÚÓÚÊý×eÖУ¬´aeÔÚÔoµ»Øtrue¡£Ò»Ð(C)¸u¾ßÌaµÄÓ¦Óüǵòe¿´ÊÖ²a£¡

array_values();
array array_values ( array input )
Óearray_keys()ÀaËÆ£¡*µ»ØµÄÊÇÊý×eµÄËuÓмuÖµ£¡

array_search();
mixed array_search ( mixed needle,array haystack [, bool strict] )
ÔÚ haystackÖÐËÑË÷ needle²ÎÊý²¢ÔÚÕÒµ½µÄÇe¿oϵ»Ø¼uÃu£¬ñÔoµ»Ø FALSE ¡£
Èç¹uneedleÊÇ×Ö
u´®£¬Ôo±È½ÏÇøÖ´oСд£¡
Èç¹ustrictÊÇtrue£¬»¹µÃ±È½ÏÀaÐÍ
Èç¹uneedleÔÚhaystackÖгoÏÖ²»Ö¹Ò»´Î£¬Ôo
µ»ØµÚÒ»¸oÆ¥ÅaµÄ¼u¡£Òª*µ»ØËuÓÐÆ¥ÅaÖµµÄ¼u£¬Ó¦¸ÃÓÃarray_keys()¼ÓÉÏ¿ÉÑ¡²ÎÊýsearch_valueÀ´´uÌae£¡

Traversing arrays

key();
mixed key ( array &array; )
*µ»ØÊý×eÖе±Ç°µ¥ÔªµÄ¼uÃu£¡

reset();
ÖØÖÃÊý×eµÄÖ¸Õe¡£

each();
*µ»ØÊý×eÖе±Ç°µ¥ÔªµÄ¼u /Öµ¶Ô£¬²¢½«Ö¸ÕeÏÂÒÆһλ£¡

current();
µ»Øµ±Ç°±»ÄÚ²¿Ö¸ÕeÖ¸ÏoµÄÊý×eµ¥ÔªµÄÖµ£¬²¢²»Òƶ¯Ö¸Õe¡£Èç¹u³¬³oÁ˵¥ÔªÁбiµÄÄ(C)¶Ë£¬Ôoµ»Ø false¡£

end();
½« arrayµÄÄÚ²¿Ö¸ÕeÒƶ¯µ½×iºoÒ»¸oµ¥Ôª²¢*µ»ØÆaÖµ¡£

next();
µ»ØÊý×eÄÚ²¿Ö¸ÕeÖ¸ÏoµÄÏÂÒ»¸oµ¥ÔªµÄÖµ£¬»oµ±Ã»Óиu¶aµ¥ÔªÊ±µ»Ø FALSE ¡£

prev();
µ»ØÊý×eÄÚ²¿Ö¸ÕeÖ¸ÏoµÄÇ°Ò»¸oµ¥ÔªµÄÖµ£¬»oµ±Ã»Óиu¶aµ¥ÔªÊ±µ»Ø FALSE ¡£

array_walk();
bool array_walk ( array &array;,callback funcname [, mixed userdata] )
¾ßÌaÃeÊoÇe²Î¿¼ÊÖ²a£¡
ʾÀý£º

array_reverse();
array array_reverse ( array array [,bool preserve_keys] )
½ÓÊÜÊý×e array×÷ΪÊaÈe²¢µ»ØÒ»¸oµ¥ÔªÎªÏa´Ë³ÐoµÄÐÂÊý×e£¬Èç¹u preserve_keysΪ TRUE Ôo±£ÁoÔ­À´µÄ¼uÃu¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$states =array( ¡®Delaware' , ¡®Pennsylvania' , ¡®New Jersey' );
print_r ( array_reverse ( $states ));
//Array ([0]=>New Jersey [1]=>Pennsylvania[2]=>Delaware)
$states = array( ¡®Delaware' , ¡®Pennsylvania' , ¡®New Jersey' );
print_r ( array_reverse ( $states , 1 ));
//Array ([2]=>New Jersey [1]=>Pennsylvania[0]=>Delaware)

`

array_flip();
array array_flip ( array trans )
½»»»Êý×eÖеļu /Öµ¶Ô£¬×¢Òa trans ÖеÄÖµÐeÒªÄܹ»×÷ΪºÏ¨µÄ¼uÃu£¬ÀýÈçÐeÒªÊÇ integer »oÕß string ¡£Èç¹uÖµµÄÀaÐͲ»¶Ô½«¢³oÒ»¸o¾¯¸ae£¬²¢ÇÒÓÐÎÊÌaµÄ¼u£¯Öµ¶Ô½«²»»a*´×ª¡£
Èç¹uͬһ¸oÖµ³oÏÖÁ˶a´Î£¬Ôo×iºoÒ»¸o¼uÃu½«×÷ΪËuµÄÖµ£¬ËuÓÐÆaËuµÄ¶¼¶ªÊ§ÁË¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$trans =array( "a" => 1 , "b" => 1 , "c" => 2 );
$trans = array_flip ( $trans );
print_r ( $trans );
//Array([1]=>b[2]=>c );

`

Determining array size and element uniqueness

count();
¼ÆËaÊý×eÖеĵ¥ÔªÊýÄ¿»o¶ÔÏoÖеÄÊoÐÔ¸oÊý£¬ºÜ»u±¾Å¶£¡

array_count_values();
*µ»ØÒ»¸oÊý×e£¬¸ÃÊý×eÓÃinputÊý×eÖеÄÖµ×÷Ϊ¼uÃu£¬¸ÃÖµÔÚinputÊý×eÖгoÏֵĴÎÊý×÷Ϊֵ¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$array= array( 1 , "hello" , 1 , "world" , "hello" );
print_r ( array_count_values ( $array ));

`

array_unique();
array array_unique ( array array )
½ÓÊÜ array×÷ΪÊaÈe²¢*µ»ØûÓÐÖظ´ÖµµÄÐÂÊý×e¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$input =array( "a" => "green" , "red" , "b" => "green" , "blue" , "red" );
$result = array_unique ( $input );
print_r ( $result );

`

ÏeϸÓÃ*¨Çe²Î¼uÊÖ²a£¡

Sorting arrays

sort();
±¾º¯Êý¶ÔÊý×e½øÐÐÅÅÐo¡£µ±±¾º¯Êý½aÊøʱÊý×eµ¥Ôª½«±»´Ó×iµÍµ½×i¸ßÖØа²ÅÅ¡£
×¢Òa : ±¾º¯ÊýΪarrayÖеĵ¥Ôª¸³ÓeеļuÃu¡£Õa½«É¾³ýÔ­ÓеļuÃu¶ø²»½oÊÇÖØÐÂÅÅÐo¡£

natsort();
ÀuÓÃ×ÔÈ»ÅÅÐo*¨¶ÔÊý×e½øÐÐÅÅÐo£¡
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$array1 = $array2 = array( "img12.png" , "img10.png" , "img2.png" , "img1.png" );
sort ( $array1 );
echo "Standard sorting\n" ;
print_r ( $array1 );

natsort ( $array2 );
echo "\nNatural order sorting\n" ;
print_r ( $array2 );

`

natcasesort();
Óe natsort()Ò»Ö£¬³ýÁ˲»Çø*Ö´oСд£¡

rsort();
Óe sort()Ò»Ö£¬Õa¸oÊÇÄaeÏoÅÅÐo¡£
asort();
Óe sort()Ò»Ö±£¬µ«±£³Ö¼uÃu²»±a¡£
array_multisort();
¶Ô¶a¸oÊý×e»o¶aάÊý×e½øÐÐÅÅÐo£¬¾ßÌa²Î¿¼ÊÖ²a£¬ÓÐÏeϸ˵Ã÷£¡
arsort();
Óe rsort()ÀaËÆ£¬µ«±£³Ö¼uÃu²»±a¡£
ksort();
Óe sort()ÀaËÆ£¬¶Ô¼uÃu½øÐÐÅÅÐo¡£
krsort();
Óe ksort()ÀaËÆ£¬µ«ÊÇÄaeÏoÅÅÐo¡£
usort();
ÀuÓÃÓû§×Ô¶¨Òaº¯Êý¶ÔÊý×e½øÐÐÅÅÐo£¡

Merging, slicing, splicing, and dissectingarrays

array_combine();
array array_combine ( array keys,array values )
´´½¨Ò»¸oÊý×e£¬ÓÃÒ»¸oÊý×eµÄÖµ×÷ΪÆa¼uÃu£¬ÁiÒ»¸oÊý×eµÄÖµ×÷ΪÆaÖµ

array_merge();
array array_merge ( array array1 [,array array2 [, array ...]] )
½«Ò»¸o»o¶a¸oÊý×eµÄµ¥ÔªºÏ²¢ÆðÀ´£¬Ò»¸oÊý×eÖеÄÖµ¸½¼ÓÔÚÇ°Ò»¸oÊý×eµÄºoÃae¡£µ»Ø×÷Ϊ½a¹uµÄÊý×e¡£
Èç¹uÊaÈeµÄÊý×eÖÐÓÐÏaͬµÄ×Ö
u´®¼uÃu£¬Ôo¸Ã¼uÃuºoÃaeµÄÖµ½«¸²¸ÇÇ°Ò»¸oÖµ¡£
È»¶ø£¬Èç¹uÊý×e°uº¬Êý×Ö¼uÃu£¬ºoÃaeµÄÖµ½«²»»a ¸²¸ÇÔ­À´µÄÖµ£¬¶øÊǸ½¼Óµ½ºoÃae¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$array1 =array( "color" => "red" , 2 , 4 );
$array2 = array( "a" , "b" , "color" => "green" , "shape" => "trapezoid" , 4 );
$result = array_merge ( $array1 , $array2 );
print_r ( $result );

`

Èç¹uÖ»¸øÁËÒ»¸oÊý×e²¢ÇÒ¸ÃÊý×eÊÇÊý×ÖË÷ÒýµÄ£¬Ôo¼uÃu»aÒÔÁ¬Ðø*½Ê½ÖØÐÂË÷Òý¡£

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$array1 = array();
$array2 = array( 1 => "data" );
$result = array_merge ( $array1 , $array2 );

`

Èç¹uÄaÏeÍeÈ«±£ÁoÔ­ÓÐÊý×e²¢Ö»ÏeеÄÊý×e¸½¼Óµ½ºoÃae£¬ÓÃ+ÔËËa*u£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$array1 = array();
$array2 = array( 1 => "data" );
$result = $array1 + $array2 ;

`

array_merge_recursive();
array array_merge_recursive ( arrayarray1 [, array ...] )
½«Ò»¸o»o¶a¸oÊý×eµÄµ¥ÔªºÏ²¢ÆðÀ´£¬Ò»¸oÊý×eÖеÄÖµ¸½¼ÓÔÚÇ°Ò»¸oÊý×eµÄºoÃae¡£µ»Ø×÷Ϊ½a¹uµÄÊý×e¡£
Èç¹uÊaÈeµÄÊý×eÖÐÓÐÏaͬµÄ×Ö
u´®¼uÃu£¬ÔoÕaÐ(C)Öµ»a±»ºÏ²¢µ½Ò»¸oÊý×eÖÐÈ¥£¬Õa½«µÝ¹eÏÂÈ¥£¬Òo´ËÈç¹uÒ»¸oÖµ±¾ÉiÊÇÒ»¸oÊý×e£¬±¾º¯Êý½«°´ÕÕÏaÓ¦µÄÌoÄ¿°ÑËuºÏ²¢ÎªÁiÒ»¸oÊý×e¡£È»¶ø£¬Èç¹uÊý×e¾ßÓÐÏaͬµÄÊý×e¼uÃu£¬ºoÒ»¸oÖµ½«²»»a¸²¸ÇÔ­À´µÄÖµ£¬¶øÊǸ½¼Óµ½ºoÃae¡£

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$ar1 = array( "color" =>array( "favorite" => "red" ), 5 );
$ar2 = array( 10 , "color" => array( "favorite" => "green" , "blue" ));
$result = array_merge_recursive ( $ar1 , $ar2 );
print_r ( $result );

`

¸uÏeϸµÄʹÓÃÇe²Î¼ÓÊÖ²a£¡

array_slice();
array array_slice ( array array, intoffset [, int length [, bool preserve_keys]] )
´ÓÊý×eÖÐÈ¡³oÒ»¶Î¡£
Èç¹uoffsetǸº£¬ÔoÐoÁн«´ÓarrayÖеĴËÆ«ÒÆÁ¿¿ªÊ¼¡£Èç¹uoffsetΪ¸º£¬ÔoÐoÁн«´ÓarrayÖоaÀeÄ(C)¶ËÕaôԶµÄµØ½¿ªÊ¼¡£
Èç¹u¸ø³oÁËlength²¢ÇÒΪÕý£¬ÔoÐoÁÐÖн«¾ßÓÐÕaô¶aµÄµ¥Ôª¡£Èç¹u¸ø³oÁËlength²¢ÇÒΪ¸º£¬ÔoÐoÁн«ÖÕÖ¹ÔÚ¾aÀeÊý×eÄ(C)¶ËÕaôԶµÄµØ*½¡£Èç¹uÊ¡ÂÔ£¬ÔoÐoÁн«´Óoffset¿ªÊ¼Ò»Ö±µ½arrayµÄÄ(C)¶Ë¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$input = array( "a" , "b" , "c" , "d" , "e" );
$output = array_slice ( $input , 2 ); // returns"c", "d", and "e"
$output = array_slice ( $input , - 2 , 1 ); // returns "d"
$output = array_slice ( $input , 0 , 3 ); // returns "a","b", and "c"
// note the differences in the array keys
print_r ( array_slice ( $input , 2 , - 1 ));
print_r ( array_slice ( $input , 2 , - 1 , true ));

`

array_splice();
array array_splice ( array&input;, int offset [, int length [, array replacement]] )
°ÑinputÊý×eÖÐÓÉoffsetºÍlengthÖ¸¶¨µÄµ¥ÔªÈ¥µo£¬Èç¹uÌa¹(C)ÁËreplacement²ÎÊý£¬ÔoÓÃreplacementÊý×eÖеĵ¥ÔªÈ¡´u¡£µ»ØÒ»¸o°uº¬Óб»ÒƳýµ¥ÔªµÄÊý×e¡£×¢ÒainputÖеÄÊý×Ö¼uÃu²»±»±£Áo¡£
Èç¹uoffset
Ǹº£¬ÔoÐoÁн«´ÓarrayÖеĴËÆ«ÒÆÁ¿¿ªÊ¼¡£Èç¹uoffsetΪ¸º£¬ÔoÐoÁн«´ÓarrayÖоaÀeÄ(C)¶ËÕaôԶµÄµØ½¿ªÊ¼¡£
Èç¹u¸ø³oÁËlength²¢ÇÒΪÕý£¬ÔoÐoÁÐÖн«¾ßÓÐÕaô¶aµÄµ¥Ôª¡£Èç¹u¸ø³oÁËlength²¢ÇÒΪ¸º£¬ÔoÐoÁн«ÖÕÖ¹ÔÚ¾aÀeÊý×eÄ(C)¶ËÕaôԶµÄµØ
½¡£Èç¹uÊ¡ÂÔ£¬ÔoÐoÁн«´Óoffset¿ªÊ¼Ò»Ö±µ½arrayµÄÄ(C)¶Ë¡£
¾ßÌaÓ¦ÓòμuÊÖ²a£¡

array_intersect();
array array_intersect ( arrayarray1, array array2 [, array ...] )
*µ»ØÒ»¸oÊý×e£¬¸ÃÊý×e°uº¬ÁËËuÓÐÔÚ array1 ÖÐҲͬʱ³oÏÖÔÚËuÓÐÆaËu²ÎÊýÊý×eÖеÄÖµ¡£×¢Òa¼uÃu±£Áo²»±a¡£
ʾÀý£º

¸´ÖÆPHPÄÚÈݵ½¼oÌu°a

PHP´uÂe:

`$array1 =array( "a" => "green" , "red" , "blue" );
$array2 = array( "b" => "green" , "yellow" , "red" );
$result = array_intersect ( $array1 , $array2 );

`

array_intersect_assoc();
×¢ÒaºÍ array_intersect()²»Í¬µÄÊǼuÃuÒ²ÓÃÓڱȽϡ£

array_diff();
Óe array_intersect()ÀaËÆ£¬Ö»²»¹ýËuÊǼÆËaÊý×eµÄ²i¼¯

array_diff_assoc();
Óe array_intersect_assoc()ÀaËÆ£¬Ö»²»¹ýËuÊǼÆËaÊý×eµÄ²i¼¯

Other useful array functions

array_rand();
mixed array_rand ( array input [,int num_req] )
´ÓÊý×eÖÐËae»uÈ¡³oÒ»¸o»o¶a¸oµ¥Ôª¡£

shuffle();
bool shuffle ( array &array; )
±¾º¯Êý´oÂÒ£¨Ëae»uÅÅÁе¥ÔªµÄ˳Ðo£(C)Ò»¸oÊý×e¡£
±¾º¯ÊýΪ array Öеĵ¥Ôª¸³ÓeеļuÃu¡£Õa½«É¾³ýÔ­ÓеļuÃu¶ø²»½oÊÇÖØÐÂÅÅÐo¡£

array_sum();
½«Êý×eÖеÄËuÓÐÖµµÄºÍÒÔÕuÊý»o¸¡µaÊýµÄ½a¹u*µ»Ø¡£

array_chunk();
array array_chunk ( array input, intsize [, bool preserve_keys] )
½«Ò»¸oÊý×e*Ö¸i³É¶a¸oÊý×e£¬ÆaÖÐÿ¸oÊý×eµÄµ¥ÔªÊýÄ¿ÓÉ size ¾o¶¨¡£×iºoÒ»¸oÊý×eµÄµ¥ÔªÊýÄ¿¿ÉÄÜ»aÉÙ¼¸¸o¡£µÃµ½µÄÊý×eÊÇÒ»¸o¶aάÊý×eÖеĵ¥Ôª£¬ÆaË÷Òý´ÓÁa¿ªÊ¼¡£
½«¿ÉÑ¡²ÎÊýpreserve_keys ÉeΪ TRUE£¬¿ÉÒÔʹ PHP ±£ÁoÊaÈeÊý×eÖÐÔ­À´µÄ¼uÃu¡£Èç¹uÄaÖ¸¶¨ÁË FALSE£¬ÄÇÿ¸o½a¹uÊý×e½«ÓôÓÁa¿ªÊ¼µÄÐÂÊý×ÖË÷Òý¡£Ä¬ÈÏÖµÊÇ FALSE

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例