PHP opens TXT, writes to Mysql, involves file reading, string array change and time format and change.
this time, this time to guide a batch of data to MySQL, add something that has not written a few details of PHP for a few months, so here is a record. Deepen your memory, so as not to forget it in the future.
1, the way to open a file: $fileopen = fopen ($filepath,'rt');
r refers to the mode of reading, which is converted to a binary file, and naturally the physical address of a file is not the same as the path formula, but' / 'is a portability. Higher, window is a compatible
2, check the file to the end, while (! Feof ($fileopen)) {* * * * * * * * *}
5, intercepting string, remove the last character, $ss = substr ($theV[1], 0, -1);
7, can see clearly, and the opposite of explode, implode, array is combined into string, $ss = implode ($s_ary, "); I a.quot; / / / / / March 10, 2001, 5:16 pm
$today = date (.Quot; m.d.y.quot;); / / / 03.10.01
$today = date; / / / 10, 3. Te ('h-i-s, j-m-y, it is w Day z); / / / 05-16-17, 10-03-01, 163116186 Fripm01
$today. / / / / 17:03:17 m is month
$today = date (.Quot; H:i:s.quot;); / / / 17:16:17
Handbook, but the most commonly used is
date; / / / / always conforms to the idea of China Think, must write about the time operation class, first go to CSDN to see if others have written, although it is not very troublesome to write one, but since the choice of PHP is the choice of the advantage of open source.
time operation is a good package, such as the standard Day data, according to the Y-m-d arrangement, can be direct days, or month, and with hours, minutes, can be directly - hours and minutes, seconds, automatically conversion results.
it is more convenient to use as much as possible!