Giter Site home page Giter Site logo

html-4.1-to-5-css-tags's People

Watchers

 avatar  avatar

html-4.1-to-5-css-tags's Issues

Html-4.1-to-5-css-Tags

<?php


$arTag = explode("|", "width|height|border|cellSpacing|cellPadding|vAlign|ALIGN|HSPACE|class|align|VSPACE|BORDER");

$f = file_get_contents(__DIR__."/1.txt");
preg_match_all("/\<[a-zA-z]+ (.*?)\>/is", $f, $pma);
foreach($pma[0] as $n=>$m){
    $gs = $m;
    unset($q, $q2);
    preg_match_all("/([a-zA-Z]+)=(.*?)( |\>)/is", $m, $pma2);
    foreach($pma2[0] as $n1=>$m1){
        if(!empty($m1)){

            if(in_array(trim($pma2[1][$n1]), $arTag)){

                $m = str_replace($m1, "", $m);
                if($pma2[1][$n1] == "class"){
                    $q2[] = $pma2[2][$n1];
                }else{
                    if($pma2[1][$n1] == "align"){
                        $pma2[1][$n1] = "text-align";
                    }elseif($pma2[1][$n1] == "vAlign"){
                        $pma2[1][$n1] = "vertical-align";   
                    }elseif($pma2[1][$n1] == "cellSpacing" || $pma2[1][$n1] == "cellPadding"){
                        $pma2[1][$n1] = "border-collapse";  
                        $pma2[2][$n1] = "collapse"; 
                    }
                    $q[] = mb_strtolower($pma2[1][$n1]).": ".mb_strtolower(is_numeric($pma2[2][$n1]) && $pma2[2][$n1] != 0 ? $pma2[2][$n1]."px": $pma2[2][$n1] ).";";
                }
            }
        }
    }
    $q = array_unique($q);
    $text .= !empty($q) ? "\n".".uN_".$n." {".implode(" ", $q). "}" : "";

    if(!empty($q)){
        if($gs != $m){
            //echo "\n<br>".$m;
            if(substr($m, -1) != ">"){ $m .= " >";}
            $m = str_replace(">", " class='uN_".$n." ".(!empty($q2) ? implode(" ", $q2) : "")."' >", $m);
            $f = str_replace($gs, $m, $f);
        }
    }
    //foreach()
    //print_r($pma2);
}
echo $text;
echo $f;


//print_r($pma);
 ?>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.