original_string: public static function closeOpenTags($html)
      {
          preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU", $html, $result);
          $openedTags = $result[1];
          preg_match_all("#</([a-z]+)>#iU", $html, $result);
          $closedTags = $result[1];
          $lenOpened = count($openedTags);
  
          if (count($closedTags) == $lenOpened) {
              return $html;
          }
  
          $openedTags = array_reverse($openedTags);
          for ($i = 0; $i < $lenOpened; $i++) {
              if (!in_array($openedTags[$i], $closedTags)) {
                  $html .= '</' . $openedTags[$i] . '>';
              } else {
                  unset($closedTags[array_search($openedTags[$i], $closedTags)]);
              }
          }
  
          return $html;
      }
code: public static function closeOpenTags($html)
      {
          preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU", $html, $result);
          $openedTags = $result[1];
          preg_match_all("#</([a-z]+)>#iU", $html, $result);
          $closedTags = $result[1];
          $lenOpened = count($openedTags);
  
          if (count($closedTags) == $lenOpened) {
              return $html;
          }
  
          $openedTags = array_reverse($openedTags);
          for ($i = 0; $i < $lenOpened; $i++) {
              if (!in_array($openedTags[$i], $closedTags)) {
                  $html .= '</' . $openedTags[$i] . '>';
              } else {
                  unset($closedTags[array_search($openedTags[$i], $closedTags)]);
              }
          }
  
          return $html;
      }
code_tokens: public static function closeOpenTags ( $ html ) { preg_match_all ( "#<([a-z]+)( .*)?(?!/)>#iU" , $ html , $ result ) ; $ openedTags = $ result [ 1 ] ; preg_match_all ( "#</([a-z]+)>#iU" , $ html , $ result ) ; $ closedTags = $ result [ 1 ] ; $ lenOpened = count ( $ openedTags ) ; if ( count ( $ closedTags ) == $ lenOpened ) { return $ html ; } $ openedTags = array_reverse ( $ openedTags ) ; for ( $ i = 0 ; $ i < $ lenOpened ; $ i ++ ) { if ( ! in_array ( $ openedTags [ $ i ] , $ closedTags ) ) { $ html .= '</' . $ openedTags [ $ i ] . '>' ; } else { unset ( $ closedTags [ array_search ( $ openedTags [ $ i ] , $ closedTags ) ] ) ; } } return $ html ; }
docstring: Attempts to close any unclosed HTML tag.
  
  @param string $html HTML content to fix
  @return string
docstring_tokens: Attempts to close any unclosed HTML tag .