Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php close unclosed HTML Tags

function closetags($html) {
    preg_match_all('#<(?!meta|img|br|hr|input)([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
    $openedtags = $result[1];
    preg_match_all('#</([a-z]+)>#iU', $html, $result);
    $closedtags = $result[1];
    $len_opened = count($openedtags);
    if (count($closedtags) == $len_opened) {
        return $html;
    }
    $openedtags = array_reverse($openedtags);
    for ($i=0; $i < $len_opened; $i++) {
        if (!in_array($openedtags[$i], $closedtags)) {
            $html .= '</'.$openedtags[$i].'>';
        } else {
            unset($closedtags[array_search($openedtags[$i], $closedtags)]);
        }
    }
    return $html;
} 
Comment

PREVIOUS NEXT
Code Example
Php :: how to get yearly chart in laravel 
Php :: moodle get course image 
Php :: php rand int 
Php :: Proc file for laravel 
Php :: php array subset by slicing 
Php :: wp main menu 
Php :: how to link image in laravel 
Php :: check if value change laravel 
Php :: laravel query order by relation 
Php :: replace text in string php 
Php :: update profile method in laravel 
Php :: is serialized php 
Php :: php ip log 
Php :: how to get attachments to emails php 
Php :: php sodium extension xampp 
Php :: laravel create model controller and migration on line 
Php :: php print datetime 
Php :: array search multidimensional php 
Php :: laravel collection average 
Php :: laravel carbon time format 
Php :: comment php 
Php :: php clean user input 
Php :: php artisanmigrate 
Php :: how to trim string in laravel 
Php :: codeigniter base_url 
Php :: how get the photo size upload in laravel 
Php :: Tenant could not be identified on domain tenancy 
Php :: php url parameters 
Php :: php define class 
Php :: php if elseif endif 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =