stripslashes

Un-quotes a quoted string

Syntax

stripslashes ( string $str ) : string

Parameters

str

The input string.

Return

Returns a string with backslashes stripped off. A backslash with a single quote (\') becomes a single quote ('). A double backslash (\\) becomes a single backslash (\). And so on.

Examples

1 · str

<?

$str = "twelve o\'clock";

$return = stripslashes($str);

echo $return;

?>
twelve o'clock

2 · Recursive

<?

function stripslashesrecursive($value) {
    if (is_array($value)) {
        $value = array_map('stripslashesrecursive', $value);
    } else {
        $value = stripslashes($value);
    }
    return $value;
}

$array = array("one o\'clock", "two o\'clock", array("three o\'clock", "four o\'clock"));

$return = stripslashesrecursive($array);

print_r($return);

?>
Array
(
    [0] => one o'clock
    [1] => two o'clock
    [2] => Array
        (
            [0] => three o'clock
            [1] => four o'clock
        )

)
HomeMenu