private function removeComments( $input, $proxy = false )
  {
    if ( preg_match_all("/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\//", $input, $comments) )
    {
      foreach ( $comments[ 0 ] as $comment )
      {
        $lines = explode(PHP_EOL, $comment);
        $newComment = implode(PHP_EOL,preg_grep("/copyright|license|author|preserve|credit|http|\/\*\!/i",$lines));

        if($newComment)
        {
          // Add proper comment encapsulation
          if ( count( $lines ) > 1 )
          {
            $prefix = (substr($newComment,0,3) == '/*!') ? '' : '/*!' . PHP_EOL;
            $newComment = $prefix . $newComment . PHP_EOL . " */";
          }
          else
          {
            $newComment = str_replace( array("/* ","/** "), "/*! ", $newComment );
          }

          if($proxy) { $this->comments[] = $newComment; }

          $input = str_replace( $comment, $newComment, $input );

        }
        else
        {
          $input = str_replace( $comment, "", $input );
        }
      }

    }

    return $input;
  }
private function removeComments( $input, $proxy = false )
  {
    if ( preg_match_all("/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\//", $input, $comments) )
    {
      foreach ( $comments[ 0 ] as $comment )
      {
        $lines = explode(PHP_EOL, $comment);
        $newComment = implode(PHP_EOL,preg_grep("/copyright|license|author|preserve|credit|http|\/\*\!/i",$lines));

        if($newComment)
        {
          // Add proper comment encapsulation
          if ( count( $lines ) > 1 )
          {
            $prefix = (substr($newComment,0,3) == '/*!') ? '' : '/*!' . PHP_EOL;
            $newComment = $prefix . $newComment . PHP_EOL . " */";
          }
          else
          {
            $newComment = str_replace( array("/* ","/** "), "/*! ", $newComment );
          }

          if($proxy) { $this->comments[] = $newComment; }

          $input = str_replace( $comment, $newComment, $input );

        }
        else
        {
          $input = str_replace( $comment, "", $input );
        }
      }

    }

    return $input;
  }
private function removeComments ( $ input , $ proxy = false ) { if ( preg_match_all ( "/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\//" , $ input , $ comments ) ) { foreach ( $ comments [ 0 ] as $ comment ) { $ lines = explode ( PHP_EOL , $ comment ) ; $ newComment = implode ( PHP_EOL , preg_grep ( "/copyright|license|author|preserve|credit|http|\/\*\!/i" , $ lines ) ) ; if ( $ newComment ) { // Add proper comment encapsulation if ( count ( $ lines ) > 1 ) { $ prefix = ( substr ( $ newComment , 0 , 3 ) == '/*!' ) ? '' : '/*!' . PHP_EOL ; $ newComment = $ prefix . $ newComment . PHP_EOL . " */" ; } else { $ newComment = str_replace ( array ( "/* " , "/** " ) , "/*! " , $ newComment ) ; } if ( $ proxy ) { $ this -> comments [ ] = $ newComment ; } $ input = str_replace ( $ comment , $ newComment , $ input ) ; } else { $ input = str_replace ( $ comment , "" , $ input ) ; } } } return $ input ; }
Removes comments from a multi line string while preserving any comments that mention licenses, authors, copyrights
or the source URL of the code.  This ensures that minification does not break most open source licenses which
require attribution.

@param  string  $input
@param  bool   $proxy

@return string
Removes comments from a multi line string while preserving any comments that mention licenses authors copyrights or the source URL of the code . This ensures that minification does not break most open source licenses which require attribution .