-4
我有以下內容2個文件例如爆炸A:B爲:C PHP
FILE1.TXT 和 FILE2.TXT
FILE1.TXT包含例如:
a:b
markus:lanz
peter:heinrichs
lach:schnell
和file2.txt包含例如以下內容(file1.txt的第二次爆炸)
b:c
lanz:hallo
heinrichs:gruss
schnell:langsam
所以我想在php中輸出如下內容:
a:c
markus:hallo
peter:gruss
lach:langsam
這怎麼可能?
首先爆炸,然後搜索或如何?
感謝
我當前的代碼如下:
<?php
$file1 = 'a:b
markus:lanz
peter:heinrichs
lach:schnell';
$file2 = '
lanz:hallo
heinrichs:gruss
b:c
test:notest
schnell:langsam';
$array = explode(":", $file1);
for($i=0; $i < count($array); $i++) {
$array = explode(":", $file1);
$pattan = $array[$i];
$pattern = '=\n'. $pattan .':(.*)\n=sUm';
$result = preg_match($pattern, $file2, $subpattern);
echo "<br>";
echo $array[$i];
$first = $array[$i];
echo "<br>";
}
$pattern = '=\n'. $first .':(.*)\n=sUm';
$result = preg_match($pattern, $file2, $subpattern);
var_dump($subpattern);
?>
什麼我作出錯誤的?
你似乎是匹配位置,林不知道搜索的一點是 –
如果數據是從實際文件中讀取的,那麼你應該首先使用'file'來獲取包含單行的數組。然後循環瀏覽這些內容,並在冒號中分解它們。 – CBroe
想要例如a:b轉到a:c不重要,訂單如何是 – yarak32