Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Éî˼ PHP Êý×é±éÀúµÄ²îÒ죨array_diff µÄʵÏÖ£©

»¹ÊÇ
²¿ÃÅÎÞÁĵĿ¼Ì⣬²»¹ýÕâ´Î¿¼µÄÊÇ PHP
µÄÄÜÁ¦¡£ÌâÄ¿ÈçÏ£º
¸øÄãÁ½¸ö·Ö±ðÓÐ 5000 ¸öÔªËصÄÊý×飬¼ÆËãËûÃǵIJ
-- ˵°×ÁËÒ²¾ÍÊÇÓà PHP ºÍÄãÈÏΪ×îºÃµÄË㷨ʵÏÖ array_diff µÄËã·¨¡£
³õ´Î½Óµ½Õâ¸öÌâÄ¿£¬ÎÒ·¢ÏÖÕâ·Ç³£µÄ¼òµ¥£¬
ÓÚÊÇ°´ÕÕÒÔÍùµÄ¾­Ñé“Ëæ±ã”дÁËÒ»¸ö£º
function array_diff($array_1, $array_2) {
$diff = array();
foreach ($array_1 as $k => $v1) {
$flag = false;
foreach ($array_2 as $v2) {
if ($flag = ($v1 == $v2)) {
break;
}
}
if (!$flag) {
$diff[$k] = $v1;
}
}
return $diff;
}
ËäȻʵÏÖÊÇ¿ÉÒԵģ¬µ«ÊÇ·¢ÏÖÕâ¸öº¯ÊýµÄЧÂÊÊDzҲ»È̶á£ÓÚÊÇÎÒÓÖÖØп¼ÂÇÁËÏ£¬²¢ÓÅ»¯ÁËËã·¨£¬µÚ¶þ¸öº¯Êý¿´ÆðÀ´ÊÇÕâ¸öÑù×ӵģº
function array_diff($array_1, $array_2) {
foreach ($array_1 as $key => $item) {
if (in_array($item, $array_2, true)) {
unset($array_1[$key]);
}
}
return $array_1;
}
àÅ£¬Õâ´Î¼¸ºõ¿ÉÒÔºÍÔ­ array_diff º¯ÊýµÄËÙ¶ÈæÇÃÀÁË¡£µ«ÊÇ»¹ÓÐûÓиüÓÅ»¯µÄ°ì·¨ÄØ£¿ÓÉ ChinaUnix ÉϵÄһƪÎÄÕÂ
£¨²»ºÃÒâ
˼£¬×÷±×ÁË£©£¬ÎÒ·¢ÏÖ PHP ¾¹È»¿ÉÒÔÕâÑùд£º
function array_diff($array_1, $array_2) {
$array_2 = array_flip($array_2);
foreach ($array_1 as $key => $item) {
if (isset($array_2[$item])) {
unset($array_1[$key]);
}
}
return $array_1;
}
Õâ¸öº¯ÊýµÄЧÂʷdz£µÄ¾ªÈË£¬ÉõÖÁ±ÈÔ­ array_diff º¯ÊýµÄËٶȶ¼Òª¿ì¡£¾¿ÆäÔ­Òò£¬ÎÒÕÒµ½Á˽âÊÍ£º
ÒòΪ¼üÊǽøÐÐ HASH ×éÖ¯µÄ£¬²éÕҺܿ죻
¶ø Value Ö»ÊÇÓÉ Key ×éÖ¯´æ·Å£¬±¾ÉíûÓÐË÷Òý£¬Ã¿´Î²éÕÒ¶¼ÊDZéÀú¡£
×ܽá
ÕâËäÈ»ÊÇ PHP
ÓïÑÔµÄÒ»¸öСÇÏÃÅ£¬µ«ÔÚ±éÀúºÍ¶Ô±ÈÊý×éµÄÖµÉÏ£¬Èç¹ûÐèÒª¶Ô±ÈÖµ½«ÆäÓë¼ü·´×ªµÄÈ·±Èͨ³£µÄÖµ¶ÔÖµµÄ±È½ÏЧÂÊÒª¸ßµÃ¶à¡£
±ÈÈ磬ÉÏÃæµÄº¯Êý¶þÐèÒªµ÷Óà in_array
º¯ÊýÐèҪѭ»·ÅжÏÊÇ·ñÔÚº¯ÊýÄÚ£»¶øº¯ÊýÈýÔò½ö½öÅжÏÕâ¸öÊý×éÊÇ·ñ´æÔڸüü¾Í¿ÉÒÔÁË¡£¼ÓÉÏÊý×é¼üºÍÖµ²»Í¬µÄ×éÖ¯Ë÷Òý·½Ê½£¬Ð§ÂʱÈÏëÏóµÄ»¹¸ßÄǾͷdz£¿ÉÒÔÀí½â
ÁË¡£
¸½£¬²âÊÔÁ¬½ÓÔÚÕâÀï
£¨´ò°üÏÂÔØ
£©¡£Èç
¶Ô Javascript Êý×é·½ÃæµÄÌÖÂÛ¸ÐÐËȤ£¬¿ÉÒÔµã»÷ÕâÀï
¡£


Ïà¹ØÎĵµ£º

ÉîÈë·ÖÎö¼¸ÖÖPHP»ñÈ¡¿Í»§¶ËIPµÄÇé¿ö


PHP»ñÈ¡¿Í»§¶ËIPµÄÇé¿ö·ÖΪ£ºÃ»ÓÐʹÓôúÀí·þÎñÆ÷µÄÇé¿ö¡¢Ê¹ÓÃ͸Ã÷´úÀí·þÎñÆ÷µÄÇé¿ö¡¢Ê¹ÓÃÆÕͨÄäÃû´úÀí·þÎñÆ÷µÄÇé¿ö¡¢Ê¹ÓÃÆÛÆ­ÐÔ´úÀí·þÎñÆ÷µÄÇé¿ö¡¢Ê¹ÓøßÄäÃû´úÀí·þÎñÆ÷µÄÇé¿ö¡£
ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«»áΪ´ó¼ÒÏêϸ½éÉÜPHP»ñÈ¡¿Í»§¶ËIPµÄ¼¸ÖÖÇé¿ö·ÖÎö¡£ÎÒÃÇÔÚʹÓÃPHP»ñÈ¡µÄIP¿ÉÄÜÊÇ¿Í»§¶ËÕæʵµÄIP£¬Ò²¿ÉÄÜÊÇ´úÀí·þÎñÆ÷µÄI ......

php+mysqlÂÒÂëÎÊÌâ

ÎÊÌâÃèÊö£º
´Óphp½çÃæinsertÊý¾Ýµ½mysql£¬Ö»ÄÜÊäÈëżÊý¸öºº×Ö²»ÄÜÊäÈëÆæÊý¸öºº×Ö£¬ÊäÈëÆæÊý¸öºº×ֺ󱨓Data too long for column ”´íÎ󣬲¢Ã»Óиü¸ÄÊý¾Ý¿âÊý¾Ý¡£µ½Êý¾Ý¿â²é¿´£¬·¢ÏÖºº×Ö¶¼ÊÇÂÒÂë¡£µ«ÊÇphp½çÃæÏÔʾºº×ÖÕý³££¨µ±È»ÏÔʾµÄ¶¼ÊÇżÊý¸öºº×Ö£¬ÆæÊý¸öºº×Ö¶¼Ã»ÓÐдÈëÊý¾Ý¿â£©¡£
½â¾ö˼·£º
1.¸ü¸Ämy.i ......

PHP·þÎñÆ÷¶Ëͨ¹ýÃüÃû¹ÜµÀÓëC/C++³ÌÐòͨÐÅ

ÔÚÕ⼸ÌìµÄ¹¤×÷¹ý³ÌÖУ¬ÐèҪʵÏÖPHPÔÚ·þÎñÆ÷¶ËÄÜÓëÆäËû³ÌÐòͨÐÅ¡£ºÍÀϺÎÁ©ÈËÑо¿ÁË°ëÌ죬ÖÕÓÚ´óÖÂŪ³öÁËÒ»¸öÓÃWINDOWSµÄÃüÃû¹ÜµÀͨÐŵķ½·¨¡£
Óм¸µãÐèҪעÒâµÄ£º
PHP·þÎñÆ÷¶ËÎÒÃÇÿ´Î¶¼ÊÇÖØйҽÓÃüÃû¹ÜµÀ¡££¨ÕâÑùд£¬PHP¶Ë´úÂëÁ¿¼«ÆäÉÙ£¬¶øÇÒÒ²ºÜ·½±ã¡££©
ÄÇôÎÒÃÇÓÃC/C++дµÄÃüÃû¹ÜµÀ·þÎñÆ÷ÔòÐèҪÿ´ÎͨÐŶ¼´´½¨Ò»´Î¹ ......

PHP½»»»Êý×éÖеÄÔªËغÍÖµ

/*
author: yangyu@sina.cn
description: ½»»»Êý×éÖÐÁ½¸öÔªËصÄλÖã¬ÔªËØ°üÀ¨keyºÍvalue£¬¾ßÌåÓ÷¨¼ûÏÂÃæµÄÀý×Ó
*/
$arr = array(11=>'a',22=>'b',33=>'c',44=>'d');
$res = array_exchange($arr, 11 ,33);
//example:
echo '<pre>';print_r ($res);echo '</pre>';
function array_excha ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ