导出我的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不是一条单行道。你需要回馈它。 –