我有这个数据:
920-1063-03@0001D92E@2012-07-02 920-1063-04@00002F5F@2012-07-02 920-1063-04@00002453@2012-07-02 920-1063-03@0001D256@2012-07-02 920-1063-03@0001E225@2012-07-02 920-1063-03@0001E3C1@2012-07-02 920-1063-04@00001EA6@2012-07-02 920-1063-03@0001D316@2012-07-02 920-1063-04@00002A41@2012-07-02 920-1063-04@00001ADA@2012-07-02 920-1063-04@00002DFD@2012-07-02 920-1063-03@0001C595@2012-07-02 920-1063-04@00001C24@2012-07-02 920-1063-04@00002341@2012-07-02 920-1063-04@00001645@2012-07-02 920-1063-04@00001C04@2012-07-02
我试图用@
符号分隔。
为此,我有以下代码:
<?php
$filename = "tru_cage_DSB_sn";
$fd = fopen ($filename, "r");
$contents = fread ($fd,filesize ($filename));
fclose ($fd);
$delimiter = "@";
$splitcontents = explode($delimiter, $contents);
$counter = "";
foreach ( $splitcontents as $color ){
$counter = $counter+1;
echo "<b>Split $counter: </b> $color<br>";
}
?>
输出将是这样的:
Split 1: 920-1063-03
Split 2: 0001D92E
Split 3: 2012-07-02 920-1063-04
Split 4: 00002F5F
Split 5: 2012-07-02 920-1063-04
但是,我希望拆分也2012-07-02 920-1063-04
分成两个字符串,由空格分隔。所以输出应该是这样的?
Split 1: 920-1063-03
Split 2: 0001D92E
Split 3: 2012-07-02
Split 4: 920-1063-04
Split 5: 00002F5F
Split 6: 2012-07-02
Split 7: 920-1063-04
我该如何进一步拆分?
或者,有没有办法将这些数据直接插入到具有 3 列的 mySQL 数据库中?