本文整理汇总了PHP中array_map_recursive函数的典型用法代码示例。如果您正苦于以下问题:PHP array_map_recursive函数的具体用法?PHP array_map_recursive怎么用?PHP array_map_recursive使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_map_recursive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PsychoCMS
function PsychoCMS($conf = array())
{
// PHP4
$conf += array('dbhandle' => null, 'session' => null, 'plugin_dir' => '');
if (empty($conf['plugin_dir'])) {
$conf['plugin_dir'] = catfile(PS_ROOTDIR, 'plugins');
}
$this->conf = $conf;
// initialize input; strip those annoying slashes if needed.
// but lets be nice to the environment and not actually touch the global arrays.
if (get_magic_quotes_gpc()) {
$this->input = array_map_recursive('stripslashes', array_merge($_GET, $_POST));
$this->file = array_map_recursive('stripslashes', $_FILES);
$this->cookie = array_map_recursive('stripslashes', $_COOKIE);
} else {
$this->input = array_merge($_GET, $_POST);
$this->file = $_FILES;
$this->cookie = $_COOKIE;
}
// initialize the database connection
if (isset($conf['dbhandle']) and is_object($conf['dbhandle'])) {
$this->db =& $conf['dbhandle'];
} else {
require_once dirname(__FILE__) . "/class_DB.php";
$this->db = DB::create($conf);
}
// where are our plugins?
$this->plugin_dir = $conf['plugin_dir'];
}
示例2: array_map_recursive
function array_map_recursive($function, &$data)
{
foreach ($data as $i => $item) {
$data[$i] = is_array($item) ? array_map_recursive($function, $item) : $function($item);
}
return $data;
}
示例3: array_map_recursive
function array_map_recursive( $func, $arr ) {
$newArr = array();
foreach( $arr as $key => $value ) {
$newArr[ $key ] = ( is_array( $value ) ? array_map_recursive( $func, $value ) : $func( $value ) );
}
return $newArr;
}
示例4: array_map_recursive
function array_map_recursive($fn, $arr)
{
$rarr = array();
foreach ($arr as $k => $v) {
$rarr[$k] = is_array($v) ? array_map_recursive($fn, $v) : (is_array($fn) ? call_user_func($fn, $v) : $fn($v));
}
return $rarr;
}
示例5: array_map_recursive
function array_map_recursive($func, $arr)
{
$out = [];
foreach ($arr as $k => $x) {
$out[$k] = is_array($x) ? array_map_recursive($func, $x) : $func($x);
}
return $out;
}
示例6: array_map_recursive
function array_map_recursive(callable $closure, array $array)
{
$buf = [];
foreach ($array as $k => $v) {
$buf[$k] = is_array($v) ? array_map_recursive($closure, $v) : $closure($v);
}
return $buf;
}
示例7: array_map_recursive
function array_map_recursive($func, $arr)
{
$newArr = array();
foreach ($arr as $key => $value) {
$newArr[$key] = is_array($value) || $value instanceof ArrayAccess ? array_map_recursive($func, $value) : call_user_func($func, $value);
}
return $newArr;
}
示例8: _crud_index_before_insert_or_update
/**
* _crud_option_before_insert_or_update
*
* Do before insert
*/
function _crud_index_before_insert_or_update($post_array, $primary_key)
{
$this->load->helper('date');
$this->load->helper('security');
$post_array = array_map_recursive('xss_clean', $post_array);
$post_array = array_map_recursive('strip_tags', $post_array);
$post_array['updated'] = date('Y-m-d H:i:s', now());
return $post_array;
}
示例9: array_map_recursive
/**
* Applies the callback to the elements of the given arrays, recursively
* @param callable $callback Callback function to run for each element in each array.
* @param array $value An array to run through the callback function.
* @return array Returns an array containing all the elements of array1 after applying the callback function to each one.
*/
function array_map_recursive($callback, $value)
{
if (is_array($value)) {
return array_map(function ($value) use($callback) {
return array_map_recursive($callback, $value);
}, $value);
}
return $callback($value);
}
示例10: array_map_recursive
private function array_map_recursive($callback, $array) {
foreach ($array as $key => $value) {
if (is_object($array[$key])) {
$array[$key] = array_map_recursive($callback, $array[$key]);
} else {
$array[$key] = call_user_func($callback, $array[$key]);
}
}
return $array;
}
示例11: array_map_recursive
function array_map_recursive($func, $arr)
{
$a = array();
if (is_array($arr)) {
foreach ($arr as $k => $v) {
$a[$k] = is_array($v) ? array_map_recursive($func, $v) : $func($v);
}
}
return $a;
}
示例12: array_map_recursive
private function array_map_recursive($func, $array)
{
foreach ($array as $key => $val) {
if (is_array($array[$key])) {
$array[$key] = array_map_recursive($func, $array[$key]);
} else {
$array[$key] = call_user_func($func, $val);
}
}
return $array;
}
示例13: array_map_recursive
function array_map_recursive($callback, $array)
{
$ret = array();
if (!is_array($array)) {
return $callback($array);
}
foreach ($array as $key => $val) {
$ret[$key] = array_map_recursive($callback, $val);
}
return $ret;
}
示例14: _empty
public function _empty($name, $args)
{
require_once APP_PATH . CONTROLLER_NAME . '/' . 'Controller' . '/' . CONTROLLER_NAME . 'Controller.class.php';
$controller = A('Admin/' . CONTROLLER_NAME);
$action = ACTION_NAME;
try {
$method = new \ReflectionMethod($controller, $name);
// URL参数绑定检测
if ($method->getNumberOfParameters() > 0 && C('URL_PARAMS_BIND')) {
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
$vars = array_merge($_GET, $_POST);
break;
case 'PUT':
parse_str(file_get_contents('php://input'), $vars);
break;
default:
$vars = $_GET;
}
$params = $method->getParameters();
$paramsBindType = C('URL_PARAMS_BIND_TYPE');
foreach ($params as $param) {
$name = $param->getName();
if (1 == $paramsBindType && !empty($vars)) {
$args[] = array_shift($vars);
} elseif (0 == $paramsBindType && isset($vars[$name])) {
$args[] = $vars[$name];
} elseif ($param->isDefaultValueAvailable()) {
$args[] = $param->getDefaultValue();
} else {
E(L('_PARAM_ERROR_') . ':' . $name);
}
}
// 开启绑定参数过滤机制
if (C('URL_PARAMS_SAFE')) {
array_walk_recursive($args, 'filter_exp');
$filters = C('URL_PARAMS_FILTER') ?: C('DEFAULT_FILTER');
if ($filters) {
$filters = explode(',', $filters);
foreach ($filters as $filter) {
$args = array_map_recursive($filter, $args);
// 参数过滤
}
}
}
$method->invokeArgs($controller, $args);
} else {
$method->invoke($controller);
}
} catch (\ReflectionException $e) {
$this->error('404,您访问的页面不存在。');
}
}
示例15: toBSON
public function toBSON()
{
return array_map_recursive(function ($item) {
if (is_object($item) && ($class = get_class($item))) {
if ($item instanceof \MongoDB\BSON\Serializable) {
return $item->bsonSerialize();
} elseif ($class === 'DateTime') {
return new \MongoDB\BSON\UTCDateTime($item->getTimeStamp() . '000');
}
}
return $item;
}, $this->_data);
}