Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

stripslashes

Description

The stripslashes of String for PHP un-quotes a quoted string.

Syntax

stripslashes(
    string $string
): string

Parameters

string

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 · string

<?

$string = "twelve o\'clock";

$return = stripslashes($string);

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