WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/wp unslash

Contents

Description

Remove slashes from a string or array of strings.

This should be used to remove slashes from data passed to core API that expects data to be unslashed. Use this instead of stripslashes_deep().

Parameters

$value
(string|array) (required) String or array of strings to unslash.
Default: None

Return

(string|array) 
Unslashed $value.

Usage

 <?php wp_unslash$value ); ?> 

Example

This function can be used in replacement of stripslashes_deep(). As it is a recursive function, when an array is given, it will remove slashes in all sub-arrays too.

$arr = array(
        "Is your name O\'reilly?",
        "Person\'s Assets"
       );

$arr = wp_unslash( $arr );
/*
 Outputs: 
 array(
      "Is your name O'reilly?",
      "Person's Assets"
 );
*/

Change Log

Source File

wp_unslash() is located in wp-includes/formatting.php.

Related

Slashing Functions: wp_slash(), wp_unslash(), stripslashes_deep(), addslashes_gpc()

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.