Oihana PHP

stripDoubleQuotes.php

Table of Contents

Functions

stripDoubleQuotes()  : string
Strips a single layer of surrounding `"…"` double quotes from a string.

Functions

stripDoubleQuotes()

Strips a single layer of surrounding `"…"` double quotes from a string.

stripDoubleQuotes(string $value) : string

Compatible with RFC 7230 quoted-string unwrapping, without decoding \ quoted-pair escapes inside the value (rare for header parameters in practice).

No-op when:

  • the value is shorter than 2 characters,
  • the value does not start AND end with ",
  • only one side is quoted.
Parameters
$value : string

The string to strip.

Tags
example
stripDoubleQuotes('"hello"');   // 'hello'
stripDoubleQuotes('"');          // '"'    (too short)
stripDoubleQuotes('"hello');    // '"hello' (unmatched)
stripDoubleQuotes('hello"');    // 'hello"' (unmatched)
stripDoubleQuotes('""');         // ''
author

Marc Alcaraz

since
1.0.8
Return values
string

The string with one outer pair of double quotes removed, or the original value if no matching pair is found.

On this page

Search results