PHPѧϰ(13) Êý×éµÄ¶¨ÒåºÍÌî³ä
¡¡¡¡ÏÈÁ˽âÒ»ÏÂÊý×飬Êý×é¾ÍÊÇ°ÑÒ»×éÊý¾Ý°´Ë³Ðò·ÅÔÚÒ»Æð¡£PHPµÄÊý×éºÍÆäËüµÄÓïÑÔÊý×éÓÐÒ»µãµã²»Í¬£ºµÚÒ»£¬±£´æµÄÊý¾ÝÊÇ¿ÉÒÔÊÇÈκÎÀàÐ͵ģ»µÚ¶þ£¬Êý×éµÄË÷Òý¿ÉÒÔÊÇÊý×Ö£¬Ò²¿ÉÒÔÊÇ×Ö·û´®¡£
¡¡ ¡¡PHPµÄÊý×飬˵°×ÁË£¬¾ÍÊǹØÁªÊý¾ÝÿһÌõÊý×鶼ÊÇÒÔ[Ë÷Òý£¬Öµ]µÄÐÎʽ±£´æµÄ¡£ÆäÖÐË÷ÒýĬÈÏÊÇÒÔ0¿ªÊ¼µÄÊý×Ö¡£ÔÚδָ¶¨Ë÷Òýʱ£¬PHP»á´Ó0¿ªÊ¼×Ô¶¯ Éú³ÉË÷Òý¡£µ±Ö¸¶¨Ò»¸öË÷Òý£¬PHP»á´ÓÄãÖ¸¶¨Ë÷Òý×î´óÕýÕûÊýµÄÏÂÒ»¸öÕûÊý¿ªÊ¼¡£Èç¹ûÄãÖ¸¶¨µÄÊÇСÊý£¬PHP»áÈ¡ÕûÊý²¿·Ö×öΪË÷Òý¡£
¡¡¡¡ÁíÍâ˵˵Êý×éÆäËüһЩС¶«Î÷£º
array()¿ÉÒÔÉùÃ÷Ò»¸ö¿ÕÊý×飻
array[] = $value ÔÚÊý×é´æÔÚʱ£¬×·¼ÓÒ»¸öÊý¾Ý£»ÔÚÊý×é²»´æʱ£¬Éú³ÉÒ»¸öÊý×飬²¢×·¼ÓÊý¾Ý¡£
array[$index] = $value ÔÚÊý×é´æÔÚʱ£¬×·¼Ó»òÐÞ¸ÄÒ»¸öÊý¾Ý£»ÔÚÊý×é²»´æʱ£¬Éú³ÉÒ»¸öÊý×飬²¢×·¼ÓÊý¾Ý¡£
¡¡¡¡¿´ÏÂÃæµÄ´úÂ룺
// ÉùÃ÷Êý×é $test01 = array(); // ×·¼ÓÊý¾Ý $test01[] = "a"; // array(0 => "a"); // ×·¼ÓÒ»¸öË÷ÒýΪ"a"£¬Êý¾ÝΪ"b"µÄÊý¾Ý $test01["a"] = "b"; // array(0 => "a", "a" => "b"); // ÐÞ¸ÄË÷ÒýΪ0µÄÊý¾Ý $test01[0] = "c"; // array(0 => "c", "a" => "b"); // ÁíÒ»ÖÖÉùÃ÷·½·¨ $test02 = array("a", "b", "c"); // array(0 => "a", 1 => "b", 2 => "c"); // ËäÈ»ÉùÃ÷ÁËÒ»¸ö×Ö·û´®Ë÷ÒýµÄÊý¾Ý£¬µ«Ä¬ÈÏË÷Òý»¹ÊÇ´Ó0¿ªÊ¼ $test03 = array("a" => "a", "b", "c"); // array("a" => "a", 0 => "b", 1 => "c"); // ÉùÃ÷ÖÐ×î´óµÄË÷ÒýΪ2£¬ËäÈ»×î½üÊÇË÷ÒýÊÇ0£¬µ«Ä¬ÈÏË÷Òý»¹ÊÇ´Ó3¿ªÊ¼ $test04 = array(2 => "a", 0=>"b", "c"); // array(2 => "a", 0 => "b", 3 => "c"); // ÉùÃ÷Ò»¸öСÊýË÷Òý»áÈ¡ÆäÕûÊý²¿·Ö£»Ö¸¶¨Ë÷Òýʱ£¬»áÐÞ¸Ä֮ǰÉùÃ÷µÄÖµ $test05 = array("a", 2.7=>"b", 0=>"c"); // array(0 => "c", 2 => "b"); // ËäÈ»ÉùÃ÷Á˸ºÊýË÷Òý£¬µ«Ä¬ÈÏË÷Òý»¹ÊÇ´Ó0¿ªÊ¼ $test06 = array(-2 =>"a", "b", "c"); // array(-2 => "a", 1 => "b", 2 => "c"); // ¶àάÊý×éµÄ¶¨Òå $test07 = array($test01, $test02, $test03);¡¡¡¡È»ºó½éÉÜÊý×éµÄһЩÌî³äº¯Êý£¬ÕâЩ´ó¶à¿ÉÒÔ´ÓÊÖ²áÉϲ鵽£¬ËùÒÔÖ»×÷¼òµ¥µÄ½éÉÜ¡£
range($n, $m); Ö¸¶¨ÖµµÄ·¶Î§¡£Èçrange(2,4)Éú³ÉÊý×é array(2,3,4)¡£
count($array); È¡µÃÊý×éµÄ´óС¡£
array_pad($array, $length, $value); ·µ»ØÒ»¸ö³¤¶È$lengthµÄÊý×飬Բ»×ãÊý×鲹ֵΪ$value£¬³¤¶È×ã¹»·µ»ØÔÊý×é¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ