Reference › Functions map_deep ( mixed $value , callable $callback ): mixed
Since 4.4.0
Source wp-includes/formatting.php:5215Description Parameters Return Uses Used by Source History Maps a function to all non-iterable elements of an array or an object.
Description This is similar to array_walk_recursive() but acts upon objects too.
Parameters
$valuemixed The array, object, or scalar.
$callbackcallable The function to map onto $value. Return
mixed The value with the callback applied to all non-arrays and non-objects inside it. Uses · 1 map_deep() Maps a function to all non-iterable elements of an array or an object. Used by · 7 map_deep() Maps a function to all non-iterable elements of an array or an object. rawurlencode_deep() Navigates through an array, object, or scalar, and raw-encodes the values to be used in a URL. stripslashes_deep() Navigates through an array, object, or scalar, and removes slashes from the values. urldecode_deep() Navigates through an array, object, or scalar, and decodes URL-encoded values urlencode_deep() Navigates through an array, object, or scalar, and encodes the values to be used in a URL. wp_kses_post_deep() Navigates through an array, object, or scalar, and sanitizes content for allowed HTML tags for post content. wp_slash_strings_only() Adds slashes to only string values in an array of values. Source View on Trac ↗ View on GitHub ↗
5215 function map_deep ( $value , $callback ) { 5216 if ( is_array ( $value ) ) { 5217 foreach ( $value as $index => $item ) { 5218 $value [ $index ] = map_deep ( $item , $callback ) ; 5219 } 5220 } elseif ( is_object ( $value ) ) { 5221 $object_vars = get_object_vars ( $value ) ; 5222 foreach ( $object_vars as $property_name => $property_value ) { 5223 $value -> $property_name = map_deep ( $property_value , $callback ) ; 5224 } 5225 } else { 5226 $value = call_user_func ( $callback , $value ) ; 5227 } 5228 5229 return $value ; 5230 } History Introduced in 4.4.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/formatting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.