Code Duplication    Length = 26-27 lines in 2 locations

class/Utility.php 1 location

@@ 1382-1408 (lines=27) @@
1379
     * @return string
1380
     * @author Milian Wolff <mail -at- milianw.de>
1381
     */
1382
public static function closeTags2($html)
1383
{
1384
    // put all opened tags into an array
1385
        preg_match_all('#<([a-z]+)( .*)?(?!/)>#iU', $html, $result);
1386
    $openedtags = $result[1];
1387
1388
        // put all closed tags into an array
1389
        preg_match_all('#</([a-z]+)>#iU', $html, $result);
1390
    $closedtags = $result[1];
1391
    $len_opened = count($openedtags);
1392
        // all tags are closed
1393
        if (count($closedtags) == $len_opened) {
1394
            return $html;
1395
        }
1396
1397
    $openedtags = array_reverse($openedtags);
1398
        // close tags
1399
        for ($i = 0; $i < $len_opened; ++$i) {
1400
            if (!in_array($openedtags[$i], $closedtags)) {
1401
                $html .= '</' . $openedtags[$i] . '>';
1402
            } else {
1403
                unset($closedtags[array_search($openedtags[$i], $closedtags)]);
1404
            }
1405
        }
1406
1407
    return $html;
1408
}
1409
1410
    /**
1411
     * @author   Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson

include/functions.php 1 location

@@ 804-829 (lines=26) @@
801
 * @return string
802
 * @author Milian Wolff <mail -at- milianw.de>
803
 */
804
function lx_closetags2($html){
805
  // put all opened tags into an array
806
  preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result);
807
  $openedtags=$result[1];
808
809
  // put all closed tags into an array
810
  preg_match_all("#</([a-z]+)>#iU",$html,$result);
811
  $closedtags=$result[1];
812
  $len_opened = count($openedtags);
813
  // all tags are closed
814
  if(count($closedtags) == $len_opened){
815
    return $html;
816
  }
817
818
  $openedtags = array_reverse($openedtags);
819
  // close tags
820
  for($i=0;$i < $len_opened;$i++) {
821
    if (!in_array($openedtags[$i],$closedtags)){
822
      $html .= '</'.$openedtags[$i].'>';
823
    } else {
824
      unset($closedtags[array_search($openedtags[$i],$closedtags)]);
825
    }
826
  }
827
828
  return $html;
829
}
830
831
/**
832
 * @author   Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson