JBZoo\Utils\Filter::stripQuotes PHP Method

stripQuotes() public static method

Strip quotes.
public static stripQuotes ( string $value ) : string
$value string
return string
    public static function stripQuotes($value)
    {
        if ($value[0] === '"' && substr($value, -1) === '"') {
            $value = trim($value, '"');
        }
        if ($value[0] === "'" && substr($value, -1) === "'") {
            $value = trim($value, "'");
        }
        return $value;
    }

Usage Example

Example #1
0
 public function tstStripQuotes()
 {
     isSame('qwerty', Filter::stripQuotes('qwerty'));
     isSame('qwerty"', Filter::stripQuotes('qwerty"'));
     isSame('"qwerty', Filter::stripQuotes('"qwerty'));
     isSame('"qwerty"', Filter::stripQuotes('"qwerty"'));
     isSame("qwerty", Filter::stripQuotes('qwerty'));
     isSame("qwerty'", Filter::stripQuotes('qwerty\''));
     isSame("'qwerty", Filter::stripQuotes('\'qwerty'));
     isSame("'qwerty'", Filter::stripQuotes('\'qwerty\''));
     isSame("'qwerty\"", Filter::stripQuotes('\'qwerty"'));
     isSame("\"qwerty'", Filter::stripQuotes('"qwerty\''));
 }