本文整理汇总了PHP中PMA_arrayWalkRecursive函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_arrayWalkRecursive函数的具体用法?PHP PMA_arrayWalkRecursive怎么用?PHP PMA_arrayWalkRecursive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_arrayWalkRecursive函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_arrayWalkRecursive
/**
* calls $function for every element in $array recursively
*
* this function is protected against deep recursion attack CVE-2006-1549,
* 1000 seems to be more than enough
*
* @param array &$array array to walk
* @param string $function function to call for every array element
* @param bool $apply_to_keys_also whether to call the function for the keys also
*
* @return void
*
* @see http://www.php-security.org/MOPB/MOPB-02-2007.html
* @see http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-1549
*/
function PMA_arrayWalkRecursive(&$array, $function, $apply_to_keys_also = false)
{
static $recursive_counter = 0;
if (++$recursive_counter > 1000) {
//PMA_fatalError(__('possible deep recursion attack'));
die('possible deep recursion attack');
}
foreach ($array as $key => $value) {
if (is_array($value)) {
PMA_arrayWalkRecursive($array[$key], $function, $apply_to_keys_also);
} else {
$array[$key] = $function($value);
}
if ($apply_to_keys_also && is_string($key)) {
$new_key = $function($key);
if ($new_key != $key) {
$array[$new_key] = $array[$key];
unset($array[$key]);
}
}
}
$recursive_counter--;
}
示例2: array_merge
// because another application for the same domain could have set
// a cookie (with a compatible path) that overrides a variable
// we expect from GET or POST.
// We'll refer to cookies explicitly with the $_COOKIE syntax.
$_REQUEST = array_merge($_GET, $_POST);
}
// end check if a subform is submitted
/**
* This setting was removed in PHP 5.4, but get_magic_quotes_gpc
* always returns False since then.
*/
if (get_magic_quotes_gpc()) {
PMA_arrayWalkRecursive($_GET, 'stripslashes', true);
PMA_arrayWalkRecursive($_POST, 'stripslashes', true);
PMA_arrayWalkRecursive($_COOKIE, 'stripslashes', true);
PMA_arrayWalkRecursive($_REQUEST, 'stripslashes', true);
}
/**
* check timezone setting
* this could produce an E_STRICT - but only once,
* if not done here it will produce E_STRICT on every date/time function
* (starting with PHP 5.3, this code can produce E_WARNING rather than
* E_STRICT)
*
*/
date_default_timezone_set(@date_default_timezone_get());
/******************************************************************************/
/* parsing configuration file LABEL_parsing_config_file */
/**
* We really need this one!
*/
示例3: PMA_emptyRecursive
/**
* recursively check if variable is empty
*
* @param mixed $value the variable
*
* @return bool true if empty
*/
function PMA_emptyRecursive($value)
{
$empty = true;
if (is_array($value)) {
PMA_arrayWalkRecursive($value, function ($item) use(&$empty) {
$empty = $empty && empty($item);
});
} else {
$empty = empty($value);
}
return $empty;
}
示例4: testWalkRecursiveApplyToKeysStripSlashes
/**
* Test for PMA_arrayWalkRecursive
*
* @return void
*/
function testWalkRecursiveApplyToKeysStripSlashes()
{
$arr = array("key\\1" => 'v\\\\al1', 'k\\ey2' => array('s\\\\key1' => 'sval\\1', 's\\k\\ey2' => 's\\v\\al2'), 'key3' => 'val3');
$second = $arr;
$target = array("key1" => 'v\\al1', 'key2' => array('s\\key1' => 'sval1', 'skey2' => 'sval2'), 'key3' => 'val3');
PMA_arrayWalkRecursive($arr, 'stripslashes', true);
$this->assertEquals($arr, $target);
PMA_arrayWalkRecursive($second, 'stripslashes', true);
$this->assertEquals($second, $target);
}
示例5: PMA_arrayWalkRecursive
/**
* calls $function vor every element in $array recursively
*
* @param array $array array to walk
* @param string $function function to call for every array element
*/
function PMA_arrayWalkRecursive(&$array, $function, $apply_to_keys_also = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
PMA_arrayWalkRecursive($array[$key], $function, $apply_to_keys_also);
} else {
$array[$key] = $function($value);
}
if ($apply_to_keys_also && is_string($key)) {
$new_key = $function($key);
if ($new_key != $key) {
$array[$new_key] = $array[$key];
unset($array[$key]);
}
}
}
}