Comment detail

コメントの削除 (Nested Flatten)

token_get_all関数を使うと楽が出来ます。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
function decomment($sorce){
    $out = '';
    foreach(token_get_all($sorce) as $token){
        if(is_array($token)){
            if($token[0] != T_COMMENT){
                $out .= $token[1];
            }
        }else{
            $out .= $token;
        }
    }
    return $out;
}

Index

Feed

Other

Link

Pathtraq

loading...