stripslashes_deep()WP 2.0.0

Navigates through an array, object, or scalar, and removes slashes from the values.

Used By: wp_unslash()

No Hooks.


Mixed. Stripped value.


stripslashes_deep( $value );
$value(mixed) (required)
The value to be stripped.



#1 Remove slashes from global arrays

Suppose we need to clear the global arrays $_POST, $_GET, $_COOKIE, or $_REQUEST from slashes while developing our application in the WordPress environment.

For example, we create a contact page in which we use a form to send a message. To get data without slashes sent through this form, we can pass the entire $_POST array through the function:

$_POST = stripslashes_deep( $_POST );

The function will go through all data, even if the array is multidimensional, and remove \ from all array values and sub-arrays.


#2 Good code practice

WordPress adds slashes to $_POST/$_GET/$_REQUEST/$_COOKIE regardless of what get_magic_quotes_gpc() returns. Therefore, in the context of WordPress, you should always remove escaped slashes when using these global variables.


$my_post = stripslashes_deep( $_POST );
$my_value = $my_post['value'];


$my_value = stripslashes( $_POST['value'] );


Since 2.0.0 Introduced.

stripslashes_deep() code WP 6.5.3

function stripslashes_deep( $value ) {
	return map_deep( $value, 'stripslashes_from_strings_only' );