Code Duplication    Length = 26-27 lines in 2 locations

class/Utility.php 1 location

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

include/functions.php 1 location

@@ 956-981 (lines=26) @@
953
 * @return string
954
 * @author Milian Wolff <mail -at- milianw.de>
955
 */
956
function lx_closetags2($html){
957
  // put all opened tags into an array
958
  preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result);
959
  $openedtags=$result[1];
960
961
  // put all closed tags into an array
962
  preg_match_all("#</([a-z]+)>#iU",$html,$result);
963
  $closedtags=$result[1];
964
  $len_opened = count($openedtags);
965
  // all tags are closed
966
  if(count($closedtags) == $len_opened){
967
    return $html;
968
  }
969
970
  $openedtags = array_reverse($openedtags);
971
  // close tags
972
  for($i=0;$i < $len_opened;$i++) {
973
    if (!in_array($openedtags[$i],$closedtags)){
974
      $html .= '</'.$openedtags[$i].'>';
975
    } else {
976
      unset($closedtags[array_search($openedtags[$i],$closedtags)]);
977
    }
978
  }
979
980
  return $html;
981
}
982
983
/**
984
 * @author   Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson