Ad

A string can come in single or double quotation marks. The goal is to get the chain without quotation marks. Delete only a couple of quotation marks, if more quotation marks appear, they will be part of the chain to be returned.

function removeQuotationMarks($string): string {
  if( str_starts_with($string, '"') && str_ends_with($string, '"') ||
      str_starts_with($string, "'") && str_ends_with($string, "'") 
    )
  {
    return substr($string,1,-1);
  }
  return $string;
}