我怎樣才能從一個文件(如下圖)通過php文件導入到我的mysql數據庫的信息?從php文件導入信息到mysql
我在想通過打開一個文件,插入一行到一個變量,並檢查每一行=標記,並通過檢查標記bevore = =來將信息插入到數組中。
這是正確的方式還是有更好的方法。
示例文件:
# Disc length: 926 seconds
# Revision: 0
# Processed by: cddbd v1.5PL3 Copyright (c) Steve Scherf et al.
# Submitted via: audiograbber 1.83.01
DISCID=00039c14
DTITLE=3M Littmann Stethoscope Edition/20 Beispiele zur Herz- und Lungenausku
DTITLE=ltation
DYEAR=1997
DGENRE=Medizin
TTITLE0=Normale Herztöne
TTITLE1=Dritter Herzton (physiologisch)
TTITLE2=Vierter Herzton
TTITLE3=Aortenklappenstenose
TTITLE4=Mitralklappeninsuffizienz
TTITLE5=Mittelsystolischer Klick
TTITLE6=Ventrikelseptum-Defekt
TTITLE7=Atriumseptum-Defekt
TTITLE8=Mitralklappenstenose
TTITLE9=Aortenklappeninsuffizienz
TTITLE10=normales tracheales Atemgeräusch
TTITLE11=normales vesikuläres Atemgeräusch
TTITLE12=feine Krepitation mit leichter bronchialer Atmung
TTITLE13=rauhe Krepitation
TTITLE14=bronchiale Atmung
TTITLE15=Stridor beim Einatmen
TTITLE16=Rhonchus
TTITLE17=pfeifender Rhonchus (Keuchatmen)
TTITLE18=feine Krepitation (Knisterrasseln)
TTITLE19=pleurales Reibungsgeräusch
EXTD=
EXTT0=
EXTT1=
EXTT2=
EXTT3=
EXTT4=
EXTT5=
EXTT6=
EXTT7=
EXTT8=
EXTT9=
EXTT10=
EXTT11=
EXTT12=
EXTT13=
EXTT14=
EXTT15=
EXTT16=
EXTT17=
EXTT18=
EXTT19=
PLAYORDER=
正確的方法是使用http://php.net /manual/en/function.parse-ini-file.php – MightyPork
顯示您迄今爲止編寫的代碼以獲取建議。你的解釋不清楚,所以很難說你的方法是否好。 –
檢查此https://github.com/austinhyde/IniParser/blob/master/src/IniParser.php – Tushar