導出我的SQL數據庫轉換成文本(database.txt)PHP的txt文件,文件是這樣的:閱讀與像數據庫
id|name_sname|identity|address|region|hours|destination|price;
--------------------------------------------------------------------
1|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;
2|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;
3|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;
4|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;
5|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;
6|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;
,現在我想讀的PHP文件,並把結果從各行中另一個文件:contracts.php ID = 1,其中id需要從我database.txt, 我嘗試閱讀database.txt在此模式下:
$data = file_get_contents("database.txt"); //read the file
$convert = explode("|", $data); //create array separate by new line
foreach($convert_row as $rand) {
echo $rand;
echo "<br /><hr /></br />";
}
什麼需要做的創建變量對於每個值afther /在「|」之前和每一行?像這樣: $ id,$ name,....
請在他們解決您的問題時接受答案。 https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work(對於你所有的問題,不只是這一個,例如https://stackoverflow.com/questions/41934091/2-循環與隨機和同一後,wordpress和https://stackoverflow.com/questions/29769831/multiple-if-in-if-with-get-url) – chris85
社區工作,雙向和isn不是一條單行道。你需要回饋它。 –