wpseek.com
WordPress开发者和主题制作者的搜索引擎
map_deep › WordPress Function
Since4.4.0
已弃用n/a
› map_deep ( $value, $callback )
参数: (2) |
|
返回: |
|
定义在: |
|
文档: |
Maps a function to all non-iterable elements of an array or an object.
This is similar toarray_walk_recursive()
but acts upon objects too.源码
function map_deep( $value, $callback ) { if ( is_array( $value ) ) { foreach ( $value as $index => $item ) { $value[ $index ] = map_deep( $item, $callback ); } } elseif ( is_object( $value ) ) { $object_vars = get_object_vars( $value ); foreach ( $object_vars as $property_name => $property_value ) { $value->$property_name = map_deep( $property_value, $callback ); } } else { $value = call_user_func( $callback, $value ); } return $value; }