Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重新解析文本文件中的数据_Php_Html_Pcre - Fatal编程技术网

Php 重新解析文本文件中的数据

Php 重新解析文本文件中的数据,php,html,pcre,Php,Html,Pcre,好吧,我知道这已经有一段时间了,我不确定我是否应该开始一个新的线程 但是我已经知道了如何删除中间的两个部分,所有的括号和srgba,还有alpha为零的行,但是它在文本文件中留下了一个空白。如果有任何改进,任何人都可以看到 $fh = fopen("pcmanD.txt", "r"); $fg = fopen("pcmanJ.txt", "wt"); $new_array = ""; $parts = ""; while (!feof($fh)) { $line = fgets($fh)

好吧,我知道这已经有一段时间了,我不确定我是否应该开始一个新的线程

但是我已经知道了如何删除中间的两个部分,所有的括号和srgba,还有alpha为零的行,但是它在文本文件中留下了一个空白。如果有任何改进,任何人都可以看到

$fh = fopen("pcmanD.txt", "r");
$fg = fopen("pcmanJ.txt", "wt");
$new_array = ""; $parts = "";
while (!feof($fh)) {
    $line = fgets($fh);
    $lines[] = $line;
    $newword = "";
    $match1 ="/:\s?\s?\(\s?\s?\d+,\s?\s?\d+,\s?\s?\d+,\s?\s?\d+\)\s?\s?#[a-zA-Z0-9]{6,8}\s?\s?srgba/";
    $match2 ="/^\s\s?/";
    $match3 = "/\s\(/";
    $match4 = "/\)/";
    $match5 = "/[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},0[^\.]/";

    $parts1 = preg_replace($match1,"", $line );
    $parts2 = preg_replace($match2,"", $parts1 );
    $parts3 = preg_replace($match3,",", $parts2 );
    $parts4 = preg_replace($match4,"", $parts3 );
    $parts5 = preg_replace($match5,"",$parts4);


    echo "<pre>";
    print_r($parts5);
    echo "</pre>";

    fwrite($fg, $parts5);
} 

fclose($fg);
fclose($fh);

你的代码有问题吗?听起来这是另一篇文章的延续。如果是这样的话,你应该链接到它。有点像,但它或多或少是相同的东西[链接]
$thisisit[] = "";
$thisisit2[] = "";
$countThis = 0;
$fh = fopen("sometext.txt", "r");
$new_array = ""; $parts = "";
while (!feof($fh)) {
    $line = fgets($fh);
    $line2 = $line;
    $newword = "";
    $match1 ="/^\s*?[\d]+,[\d]+/";
    $parts1 = preg_match($match1, $line, $regs);
    foreach($regs as $key => $lame) {
        $thisisit[] = $lame;
    }
    $match2 ="/(?:(\d{1,3},\d{1,3},))(\d{1,3},\d{1,3},\d{1,3},[01][\.]?[\d]*)/";
    $parts2 = preg_match($match2, $line2, $regs2);
    foreach($regs2 as $key2 => $lame2) {
        $thisisit2[] =$lame2;
    }
    $countLame = count($thisisit);
} 

echo "</script>";
$newCounter = 0;
for($i = 0; $i < (500); $i++) {
    echo  $thisisit[$i] . "<br />";
    echo $thisisit2[$newCounter] . "<br />" ;
    $newCounter = $newCounter +4;
}
fclose($fh);
42,23,162,166,48,0.156863
 43,23,162,166,47,0.156863
 44,23,167,170,67,0.219608
 45,23,162,166,47,0.156863
 46,23,167,170,67,0.219608
 47,23,162,166,37,0.117647
 48,23,162,167,32,0.0941176
                                      86,23,163,167,40,0.12549
 87,23,160,164,47,0.164706
 88,23,188,190,122,0.352941
 86,24,233,234,197,0.486275
 87,24,251,250,250,1
 88,24,251,250,250,1
 89,24,251,250,250,1