英数字とコメント部分を書き換えて図形文字を見やすくするためのPHPスクリプト

C言語の教育用に作成したPHPスクリプトC言語ソースコードのコメント部分 /*…*/ //… の文字をフルストップに、それ以外の部分のアルファベットと英数字をアンダースコアに書き換えるだけ。これでソースコード約物(やくもの)がそれなりに目立つようになる。
以下、ソースコード

<?php
//Usage: this.php [target C source code]

$a= file_get_contents_by_string($argv[1]);

$b="";
$flag_comment_slash_star=0;
$flag_comment_slash_slash=0;

for( $i=0; $i<count($a); $i++ ){

if( $a[$i]=="/" && $a[$i+1]=="*" && $flag_comment_slash_star==0 )
{
$flag_comment_slash_star=1;
$b.="/*";
$i=$i+2;
continue;
}

if( $flag_comment_slash_star==1 && $a[$i]=="*" && $a[$i+1]=="/" )
{
$flag_comment_slash_star=0;
$b.="*/";
$i=$i+2;
continue;
}

if( $a[$i]=="/" && $a[$i+1]=="/" && $flag_comment_slash_slash==0 )
{
$flag_comment_slash_slash=1;
$b.="//";
$i=$i+2;
continue;
}
else
if( $flag_comment_slash_slash==1 && $a[$i]=="\n" )
{
$flag_comment_slash_slash=0;
$b.="\n";
$i=$i;
continue;
}

$char= $a[$i];

if( mb_ereg("[A-Z]",$a[$i]) ){ $char= "_"; }
if( mb_ereg("[a-z]",$a[$i]) ){ $char= "_"; }
if( mb_ereg("[0-9]",$a[$i]) ){ $char= "_"; }

if( $flag_comment_slash_star==1 ){ $char= "."; }
if( $flag_comment_slash_slash==1 ){ $char= "."; }
if( $a[$i]=="\r" ) $char= "";
if( $a[$i]=="\n" ) $char= "\n";

$b.= $char;
}

print $b;

function file_get_contents_by_string($file){
$handle = @fopen($file,"r");
if ($handle) {
while (!feof($handle)) {
$buffer[] = fgetc($handle);
}
fclose($handle);
return $buffer;
}else{
exit("cannot open the file");
}
}