php ´úÂëÓÅ»¯Ö®¾µäÊÂÀý
½ñÌìÅöµ½ÁËÕâôһ¸öÎÊÌ⣬´¦ÀíµÄÊý×é$tempArrayΪÈçÏÂËùʾÐÎʽ£¨keyÒÑ ¾ÅÅÐò£©£¬È»ºóÒª¸ù¾ÝÕâ¸ö½á¹û½øÐзֿéµÄ´¦Àí£¬ÎÒÓõķ½·¨ÊÇ°´keyÇø·Ö¿é£¬È»ºóÔÚ½«¿é¸³¸øÆäËûµÄ±äÁ¿£¬È»ºóÔÙ½øÐÐһЩ²Ù×÷£¬ÕâÑùÓõ½Á˺ܶàµÄforºÍ foreach£¬¶øÇÒ´úÂëÁ¿Ò²ºÜ´ó£¬ËùÒÔ±»ÍË»ØÀ´ÁË¡£
¾¹ýÉÏÃæµÄÖ¸µ¼£¬·¢ÏÖÕæµÄºÃ¼òµ¥£¬ÏÖÔÚÓë´ó¼Òһͬ·ÖÏí¡£
ID |
FIELD1 |
FIELD2 | FIELD3 | FIELD4 | Key |
1 |
*** | *** | *** | *** | meat1 |
2 |
*** | *** | *** | *** | meat1 |
3 |
*** | *** | *** | *** | meat1 |
4 | *** | *** | *** | *** | meat1 |
5 |
*** | *** | *** | *** | fruit2 |
6 | *** | *** | *** | *** | fruit2 |
7 |
*** | *** | *** | *** | fruit2 |
8 |
*** | *** | *** | *** | fruit2 |
9 |
*** | *** | *** | *** | fruit2 |
10 |
*** | *** | *** | *** | food3 |
11 |
*** | *** | *** | *** | food3 |
ÏÖÔÚÓÐÈçÉÏËùʾµÄ½á¹û
ÒªÇó£ºÒª¶ÔÕâ¸öÒѾ°´key½øÐÐÅÅÐòÁ˵ÄÊý×é½øÐвÙ×÷£¬ÏàͬkeyµÄÏî½øÐд¦Àí¡£
Ìáʾ£ºÕâ¸öÊǺܵäÐ͵Äĸ×Ó±íµÄ½á¹¹£¬Ò²¾ÍÊÇ˵ÆäʵËüÊÇÁ½ÕűíµÄºÏ²¢£¬¿ÉÒÔÕâÑù´¦Àí³ÉÁ½¸öÊý×飬·½±ãÊý×éÀïÃæ¶Ô¿éµÄ²Ù×÷
array1:ID|Key
ID |
Key |
1 |
meat1 |
2 |
meat1 |
3 |
meat1 |
4 | meat1 |
5 |
fruit2 |
6 | fruit2 |
7 |
fruit2 |
8 |
fruit2 |
9 |
fruit2 |
10 |
food3 |
11 |
food3 |
array2:key => array(ID,FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,Key)
ID |
FIELD1 |
FIELD2 | FIELD3 | FIELD4 | Key |
|
meat1=> |
1 |
*** | *** | *** | *** | meat1 |
2 |
*** | *** | *** | *** | meat1 | |
3 |
*** | *** | *** | *** | meat1 | |
4 | *** | *** | *** | *** | meat1 | |
fruit2=> | 5 |
*** | *** | *** | *** | fruit2 |
6 | *** | *** | *** | *** | fruit2 | |
7 |
*** | *** | *** | *** | fruit2 | |
8 |
*** | *** | *** | *** | fruit2 | |
9 |
*** | *** | *** | *** | fruit2 | |
food3=> | 10 |
*** | *** | *** | *** | food3 |
11 |
*** | *** | *** | *** | food3 |
ʵÏÖÈçÉÏÊý×é·ÖÀë´úÂë
ÕâÑùºó£¬·ÃÎÊtempArrayµÄ¿éÊý¾Ý¾Í·Ç³£·½±ãÁË
foreach($tempArray as $row){ ¡¡¡¡array1[$row['ID']] = $row['Key']; ¡¡¡¡array2[$row['Key']][] = $row; } ·ÃÎʺʹ¦Àí´úÂë foreach($array1 as $ID => $Key){ ¡¡¡¡$this->doSomeThing($ID); ¡¡¡¡//·ÃÎÊtempArrayµÄ¿éÊý×é$array2[$Key] ¡¡¡¡$this->doSomeThing2($array2[$Key]); }
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿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¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ