function removeQuotes($str) { $matches = array(); $double = '/^"(.*)"$/'; $single = "/^\\'(.*)\\'\$/"; if (preg_match($double, $str, $matches)) { return $matches[1]; } else { if (preg_match($single, $str, $matches)) { return $matches[1]; } else { return $str; } } }