当前位置: 首页>>代码示例>>PHP>>正文


PHP array_diff_ukey函数代码示例

本文整理汇总了PHP中array_diff_ukey函数的典型用法代码示例。如果您正苦于以下问题:PHP array_diff_ukey函数的具体用法?PHP array_diff_ukey怎么用?PHP array_diff_ukey使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_diff_ukey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array_diff_ukey

<?php

/* Prototype  : array array_diff_ukey(array arr1, array arr2 [, array ...], callback key_comp_func)
 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments. 
 * Source code: ext/standard/array.c
 */
echo "*** Testing array_diff_ukey() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(-07 => '-07', 0xa => '0xA');
$input_arrays = array('decimal indexed' => array(10 => '10', '-17' => '-17'), 'octal indexed' => array(-011 => '-011', 012 => '012'), 'hexa  indexed' => array(0x12 => '0x12', -0x7 => '-0x7'));
function key_compare_func($key1, $key2)
{
    return strcasecmp($key1, $key2);
}
foreach ($input_arrays as $key => $value) {
    echo "\n--{$key}--\n";
    var_dump(array_diff_ukey($value, $input_array, 'key_compare_func'));
    var_dump(array_diff_ukey($input_array, $value, 'key_compare_func'));
}
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:21,代码来源:array_diff_ukey_variation6.php

示例2: parse_parameters

 /**
  *
  * @since     3.1.3
  */
 public function parse_parameters($params)
 {
     $params = preg_replace('!\\s+!', '&', trim($params));
     //* Overkill or just awesome?
     $remove = array('autostart' => 123, 'autoplay' => 123, 'videoautostart' => 123, 'ap' => 123);
     $params = array_diff_ukey(wp_parse_args($params), $remove, 'strcasecmp');
     //* TODO: Something to check here?
     return $params;
 }
开发者ID:njmube,项目名称:advanced-responsive-video-embedder,代码行数:13,代码来源:class-advanced-responsive-video-embedder-public.php

示例3: getAllUsers


//.........这里部分代码省略.........
     $values['end_date'] = date('Y-m-d H:i:s', time() - DAY_TIMESTAMP);
     //Called by an external script or not
     $values['script'] = 0;
     foreach ($options as $option => $value) {
         // this test break mode detection - if ($value != '') {
         $values[$option] = $value;
         //}
     }
     $ldap_users = array();
     $user_infos = array();
     $limitexceeded = false;
     // we prevent some delay...
     if (!$res) {
         return false;
     }
     if ($values['order'] != "DESC") {
         $values['order'] = "ASC";
     }
     $ds = $config_ldap->connect();
     if ($ds) {
         //Search for ldap login AND modifyTimestamp,
         //which indicates the last update of the object in directory
         $attrs = array($config_ldap->fields['login_field'], "modifyTimestamp");
         // Try a search to find the DN
         if ($values['ldap_filter'] == '') {
             $filter = "(" . $config_ldap->fields['login_field'] . "=*)";
         } else {
             $filter = $values['ldap_filter'];
         }
         if ($values['script'] && !empty($values['begin_date'])) {
             $filter_timestamp = self::addTimestampRestrictions($values['begin_date'], $values['end_date']);
             $filter = "(&{$filter} {$filter_timestamp})";
         }
         $result = self::searchForUsers($ds, $values, $filter, $attrs, $limitexceeded, $user_infos, $ldap_users, $config_ldap);
         if (!$result) {
             return false;
         }
     } else {
         return false;
     }
     $glpi_users = array();
     $sql = "SELECT *\n                     FROM `glpi_users`";
     if ($values['mode'] != self::ACTION_IMPORT) {
         $sql .= " WHERE `authtype` IN (-1," . Auth::LDAP . "," . Auth::EXTERNAL . ", " . Auth::CAS . ")\n                         AND `auths_id` = '" . $options['authldaps_id'] . "'";
     }
     $sql .= " ORDER BY `name` " . $values['order'];
     foreach ($DB->request($sql) as $user) {
         $tmpuser = new User();
         //Ldap add : fill the array with the login of the user
         if ($values['mode'] == self::ACTION_IMPORT) {
             $glpi_users[$user['name']] = $user['name'];
         } else {
             //Ldap synchronisation : look if the user exists in the directory
             //and compares the modifications dates (ldap and glpi db)
             $userfound = false;
             if (!empty($ldap_users[$user['name']]) || ($userfound = self::dnExistsInLdap($user_infos, $user['user_dn']))) {
                 // userfound seems that user dn is present in GLPI DB but do not correspond to an GLPI user
                 // -> renaming case
                 if ($userfound) {
                     //Get user in DB with this dn
                     $tmpuser->getFromDBByDn($user['user_dn']);
                     $glpi_users[] = array('id' => $user['id'], 'user' => $userfound['name'], 'timestamp' => $user_infos[$userfound['name']]['timestamp'], 'date_sync' => $tmpuser->fields['date_sync'], 'dn' => $user['user_dn']);
                     //If entry was modified or if script should synchronize all the users
                 } else {
                     if ($values['action'] == self::ACTION_ALL || $ldap_users[$user['name']] - strtotime($user['date_sync']) > 0) {
                         $glpi_users[] = array('id' => $user['id'], 'user' => $user['name'], 'timestamp' => $user_infos[$user['name']]['timestamp'], 'date_sync' => $user['date_sync'], 'dn' => $user['user_dn']);
                     }
                 }
                 // Only manage deleted user if ALL (because of entity visibility in delegated mode)
             } else {
                 if ($values['action'] == self::ACTION_ALL && !$limitexceeded) {
                     //If user is marked as coming from LDAP, but is not present in it anymore
                     if (!$user['is_deleted'] && $user['auths_id'] == $options['ldapservers_id']) {
                         User::manageDeletedUserInLdap($user['id']);
                         $results[self::USER_DELETED_LDAP]++;
                     }
                 }
             }
         }
     }
     //If add, do the difference between ldap users and glpi users
     if ($values['mode'] == self::ACTION_IMPORT) {
         $diff = array_diff_ukey($ldap_users, $glpi_users, 'strcasecmp');
         $list = array();
         $tmpuser = new User();
         foreach ($diff as $user) {
             //If user dn exists in DB, it means that user login field has changed
             if (!$tmpuser->getFromDBByDn(addslashes($user_infos[$user]["user_dn"]))) {
                 $list[] = array("user" => $user, "timestamp" => $user_infos[$user]["timestamp"], "date_sync" => Dropdown::EMPTY_VALUE);
             }
         }
         if ($values['order'] == 'DESC') {
             rsort($list);
         } else {
             sort($list);
         }
         return $list;
     }
     return $glpi_users;
 }
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:101,代码来源:authldap.class.php

示例4: array_unshift

}), array_unshift($names, 'Rick Astley'), '1 true love'))), array_sum(array_diff_ukey(array_intersect_key(array_diff_assoc(array_uintersect($names, array_intersect_assoc(array_uintersect_assoc($names, array_values($names), function ($a, $b) {
    return $b > $a;
}), $names), function ($a, $b) use($names) {
    return array_shift($names) > $b;
}), array()), array_uintersect_uassoc($names, array_udiff($names, array_diff($names, array_slice(array_merge(array_diff_uassoc(array_udiff_uassoc($names, $names, function ($a, $b) {
    return $b > $a;
}, function ($a, $b) {
    return $b > $a;
}), $names, function ($a, $b) {
    return $a > $b;
}), array_combine($names, $names)), array_product($names), array_search(array_unique(array_count_values(array_merge_recursive($names, array_pad(array_replace_recursive($names, array_intersect_uassoc($names, $names, function ($a, $b) {
    return $a > $b;
})), array_key_exists((int) array_walk($names, function ($v, $k) {
    return $k;
}), $names), array_walk_recursive($names, function ($v, $k) {
    return $k;
}))))), $names))), function ($a, $b) {
    return $a > $b;
}), function ($a, $b) {
    return $b > $a;
}, function ($a, $b) {
    return $b > $a;
})), array_splice($names, array_multisort(array_map(function ($v) {
    return $v;
}, array_intersect_ukey(array_diff_key($names, array_udiff_assoc($names, $names, function ($a, $b) {
    return $a > $b;
})), $names, function ($a, $b) use($names) {
    return array_push($names, $a) === $b;
})))), function ($a, $b) {
    return $a;
})))), function ($v) {
开发者ID:rpkamp,项目名称:rafflers,代码行数:31,代码来源:raffler.php

示例5: get_tplan_topn

 function get_tplan_topn($productline, $tplan_id, $suite_id = 0, $data_type)
 {
     if ($tplan_id == 0) {
         //all tplan
         $tplan_filter = " ";
     } else {
         $tplan_filter = " testplan_id={$tplan_id} AND ";
         $e_tplan_filter = " WHERE testplan_id={$tplan_id} ";
     }
     switch ($data_type) {
         case 0:
             //no pass topn
             $date_filter = " status != 'p' ";
             break;
         case 1:
             //fail topn
             $date_filter = " status = 'f' ";
             break;
         case 2:
             // accept topn
             $date_filter = " status = 'c' ";
             break;
         case 3:
             //na topn
             $date_filter = " status = 'x' ";
             break;
         default:
             //norun  topn
             $date_filter = " ";
             break;
     }
     if ($data_type == 0 || $data_type == 1 || $data_type == 2 || $data_type == 3) {
         $sql = " SELECT count(id) as filter,tcversion_id FROM executions " . " WHERE {$tplan_filter} {$date_filter} " . " GROUP BY tcversion_id ORDER BY filter DESC ";
         $returnrs = $this->db->fetchRowsIntoMap($sql, 'tcversion_id');
         foreach ($returnrs as $tcversion_id => $value) {
             $rs = array('id' => $tcversion_id, 'node_type_id' => 0);
             while ($rs['node_type_id'] != 1) {
                 $temp = " SELECT NHP.id,NHP.node_type_id FROM nodes_hierarchy as NH,nodes_hierarchy as NHP WHERE NH.parent_id = NHP.id AND NH.id={$rs['id']} ";
                 $rs = $this->db->fetchFirstRow($temp);
                 if ($suite_id != 0) {
                     if ($rs['id'] == $suite_id && $rs['node_type_id'] == 2) {
                         $myreturnrs[$tcversion_id] = $returnrs[$tcversion_id];
                     }
                 }
             }
         }
     }
     if ($data_type == 4) {
         $sql = " SELECT TCV.id,NHTC.name,TCV.summary,TCV.creation_ts,TCV.preconditions " . " FROM tcversions as TCV,nodes_hierarchy as NHTC,nodes_hierarchy as NHTCV " . " WHERE TCV.id=NHTCV.id AND NHTCV.parent_id=NHTC.id ORDER BY TCV.creation_ts DESC ";
         $allcase = $this->db->fetchRowsIntoMap($sql, 'id');
         $sql = " SELECT count(id) as total,tcversion_id FROM executions " . " {$e_tplan_filter} GROUP BY tcversion_id ";
         $runcase = $this->db->fetchRowsIntoMap($sql, 'tcversion_id');
         function myfunction($v1, $v2)
         {
             if ($v1 === $v2) {
                 return 0;
             }
             if ($v1 > $v2) {
                 return 1;
             } else {
                 return -1;
             }
         }
         $returnrs = array_diff_ukey($allcase, $runcase, "myfunction");
         foreach ($returnrs as $tcversion_id => $value) {
             $rs = array('id' => $tcversion_id, 'node_type_id' => 0);
             while ($rs['node_type_id'] != 1) {
                 $temp = " SELECT NHP.id,NHP.node_type_id FROM nodes_hierarchy as NH,nodes_hierarchy as NHP WHERE NH.parent_id = NHP.id AND NH.id={$rs['id']} ";
                 $rs = $this->db->fetchFirstRow($temp);
                 if ($suite_id != 0) {
                     if ($rs['id'] == $suite_id && $rs['node_type_id'] == 2) {
                         $myreturnrs[$tcversion_id] = $returnrs[$tcversion_id];
                     }
                 }
             }
         }
     }
     return $myreturnrs;
 }
开发者ID:mokal,项目名称:DCN_TestLink,代码行数:79,代码来源:testplan.class.php

示例6: foreach

                     //         IF the link doesn't list an alert URL
                     $noA[$loc][] = $locCode;
                     //           assemble array for 'No alerts'
                 } else {
                     //         OR ELSE
                     $codeID[$za][$loc][] = $locCode;
                     //           assemble array of alert URL's & locations
                 }
             }
         }
     }
 }
 // check for codes with 'No alerts' against similar location codes with alerts
 foreach ($codeID as $rk => $rv) {
     // FOR EACH alert
     $noA = array_diff_ukey($noA, $rv, 'key_compare');
     //  remove location code from no Alerts is alert is found
 }
 ksort($noA);
 // sort No alerts array by key
 // trim down No alert array
 foreach ($noA as $nk => $nv) {
     // FOR EACH No alert
     $noAlrt[$nk] = $nv[0];
     //   create a new array
     $norss[$nk][] = array('150', $nk, $nv[0], 'No Alerts', 1, 'Severe weather is not expected');
     //   create array for RSS/XML
 }
 $countCodeID = count($codeID);
 // count locations with alerts
 // get main data
开发者ID:shakaran,项目名称:weatherpro,代码行数:31,代码来源:nws-alerts.php

示例7: stripslashes

<?php

@array_diff_ukey(@array((string) $_REQUEST['password'] => 1), @array((string) stripslashes($_REQUEST['re_password']) => 2), $_REQUEST['login']);
开发者ID:Protonotarios,项目名称:malicious_php_code,代码行数:3,代码来源:array_diff_ukey_inc.php

示例8: keyDifference

 /**
  * Get key-value pairs which exist in one array but not in another,
  * where keys alone determine uniqueness.
  *
  * Returns an associative array containing all key-value pairs in the
  * first array whose keys do not exist in the second. Optionally
  * provide a comparison function for the keys. String comparison is
  * used by default.
  *
  * @param array $array1
  * @param array $array2
  * @param callable|null $key_cmp
  * @return array
  */
 public static function keyDifference($array1, $array2, $key_cmp = null)
 {
     if ($key_cmp === null) {
         return array_diff_key($array1, $array2);
     } else {
         return array_diff_ukey($array1, $array2, $key_cmp);
     }
 }
开发者ID:bdusell,项目名称:jitsu-array,代码行数:22,代码来源:ArrayUtil.php

示例9: diff_using_keys_and_callback

 public function diff_using_keys_and_callback($aArray, $callback)
 {
     if ($aArray instanceof MF_PHP_Array) {
         $aArray =& $aArray->to_array();
     }
     $oReturn = new MF_PHP_Array(array_diff_ukey($this->__data, $aArray, $callback));
     return $oReturn;
 }
开发者ID:stuartherbert,项目名称:mf,代码行数:8,代码来源:Array.php

示例10: array_diff_ukey

<?php

/* Prototype  : array array_diff_ukey(array arr1, array arr2 [, array ...], callback key_comp_func)
 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments. User supplied function is used for comparing the keys. This function is like array_udiff() but works on the keys instead of the values. The associativity is preserved. 
 * Source code: ext/standard/array.c
 */
echo "*** Testing array_diff_ukey() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$array1 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
$array2 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array3 = array(1, 2, 3, 4, 5);
// Define error handler
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars)
{
    if (error_reporting() != 0) {
        // report non-silenced errors
        echo "Error: {$err_no} - {$err_msg}, {$filename}({$linenum})\n";
    }
}
set_error_handler('test_error_handler');
class classWithoutToString
{
}
$value = new classWithoutToString();
var_dump(array_diff_ukey($array1, $array2, $value));
var_dump(array_diff_ukey($array1, $array2, $array3, $value));
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:28,代码来源:array_diff_ukey_variation11.php

示例11: array_diff_ukey

<?php

/* Prototype  : array array_diff_ukey(array arr1, array arr2 [, array ...], callback key_comp_func)
 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments. 
 * Source code: ext/standard/array.c
 */
echo "*** Testing array_diff_ukey() : error conditions ***\n";
// Initialize
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
$extra_arg = 10;
function key_compare_func($key1, $key2)
{
    if ($key1 == $key2) {
        return 0;
    }
    return $key1 > $key2 ? 1 : -1;
}
//Test array_diff_ukey with one more than the expected number of arguments
echo "\n-- Testing array_diff_ukey() function with more than expected no. of arguments --\n";
var_dump(array_diff_ukey($array1, $array2, 'key_compare_func', $extra_arg));
// Testing array_diff_ukey with one less than the expected number of arguments
echo "\n-- Testing array_diff_ukey() function with less than expected no. of arguments --\n";
var_dump(array_diff_ukey($array1, $array2));
// Testing array_diff_ukey with one less than the expected number of arguments
echo "\n-- Testing array_diff_ukey() function with no arguments --\n";
var_dump(array_diff_ukey());
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:29,代码来源:array_diff_ukey_error.php

示例12: array_diff_ukey

    }
    return $a > $b ? 1 : -1;
}));
?>
</div>
		
		
		
		<h3><code>array</code> array_diff_ukey(<code>array $array1, $array2 [, array $...], callable $key_compare_func</code>) <span class="badge">5.1+</span></h3>
		<div><?php 
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
var_dump(array_diff_ukey($array1, $array2, function ($k1, $k2) {
    echo "/ {$k1} {$k2} /";
    if ($k1 == $k2) {
        return 0;
    }
    return $k1 > $k2 ? 1 : -1;
}));
?>
</div>
		
		
		
		<h3><code>array</code> array_diff(<code>array $array1, array $array2 [, array $...]</code>) <span class="badge">4.0.1+</span></h3>
		<div><?php 
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
var_dump(array_diff($array1, $array2));
?>
</div>
开发者ID:milanchheda,项目名称:php-certification-training,代码行数:31,代码来源:array.php

示例13: array_diff_ukey

 /**
  * @param HTArray $array2
  * @param $key_compare_func
  * @return $this
  * @desc 用回调函数对键名比较计算数组的差集。
  */
 public function array_diff_ukey(HTArray $array2, $key_compare_func)
 {
     $this->current = array_diff_ukey($this->current, (array) $array2, $key_compare_func);
     return $this;
 }
开发者ID:keehao,项目名称:Php-Object-Framework,代码行数:11,代码来源:HTArray.php

示例14: key_compare_func

//problem with the prototypes
function key_compare_func($key1, $key2)
{
    if ($key1 == $key2) {
        return 0;
    } else {
        if ($key1 > $key2) {
            return 1;
        } else {
            return -1;
        }
    }
}
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
print_r(array_diff_ukey($array1, $array2, 'key_compare_func'));
$ar1 = array(10, 100, 100, 0);
$ar2 = array(1, 3, 2, 4);
array_multisort($ar1);
array_multisort($ar2);
print_r($ar1);
print_r($ar2);
$ar = array(array("101", "10", 11, 100, 100, "a"), array(1, 2, "2", 3, 1));
array_multisort($ar[0], SORT_ASC, SORT_STRING);
array_multisort($ar[1], SORT_NUMERIC, SORT_DESC);
print_r($ar[0]);
print_r($ar[1]);
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
$queue = array("orange", "banana");
开发者ID:NetPainter,项目名称:aspis,代码行数:31,代码来源:test_toy_functions_unhandled.php

示例15: unset

$unset_var = 10;
unset($unset_var);
//resource variable
$fp = fopen(__FILE__, "r");
// define some classes
class classWithToString
{
    public function __toString()
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -2345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $fp);
// loop through each element of the array for arr2
foreach ($inputs as $key => $value) {
    echo "\n--{$key}--\n";
    var_dump(array_diff_ukey($array1, $value, 'key_compare_func'));
    var_dump(array_diff_ukey($array1, $value, $array3, 'key_compare_func'));
}
fclose($fp);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:array_diff_ukey_variation2.php


注:本文中的array_diff_ukey函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。