I have the text file below. It is just a small snippet of a larger file, but you can see that the data changes in different sections. As such, I need to write my php file to read it depending on different sections.
Each section starts with a ~WORD which is cool. And I can use IF statements if one of those sections start, but how do I ignore the comments when I am processing my code and how do I have it start a new if statement when ~WORD is found in the current line that is being read?
[php]$txt_file = file_get_contents(‘welllog.txt’); //read well log file
$rows = explode("\n", $txt_file); // for each line break make a new row.
array_shift($rows);
foreach($rows as $row => $data) // run for each rown found.
{
//get row data
$row_data = preg_split(’/ +/’, $data); // If multiple spaces found, input next value into array.
$info[$row]['junk'] = $row_data[0]; // because the file starts with spaces at the front
$info[$row]['depth'] = $row_data[1];
$info[$row]['gr_edtc'] = $row_data[2];
$info[$row]['cmff'] = $row_data[3];
$info[$row]['cmrp_3ms'] = $row_data[4];
$info[$row]['tcmr'] = $row_data[5];
$info[$row]['ksdr'] = $row_data[6];
$info[$row]['ktim'] = $row_data[7]; [/php]
#--------------------------------------------------
~WELL INFORMATION
#MNEM.UNIT DATA DESCRIPTION
#---- ------ -------------- -----------------------------
STRT .F 6900.0 :START DEPTH
STOP .F 7400.0 :STOP DEPTH
COMP . Cirque Resources, LP :COMPANY
WELL . Trippell 32-16H :WELL
RANG . 90 W :Range
TOWN . 160 N :Township
#-----------------------------------------------------------------------------
#
# DEPT GR_EDTC CMFF CMRP_3MS TCMR KSDR KTIM
#
~A
6900.0 43.0127 0.0052 0.0119 0.0446 0.0001 0.0007
6900.5 37.4412 0.0060 0.0118 0.0432 0.0001 0.0009
6901.0 32.6030 0.0041 0.0123 0.0391 0.0001 0.0003
6901.5 26.2366 0.0032 0.0136 0.0324 0.0001 0.0001
6902.0 23.1347 0.0031 0.0141 0.0263 0.0000 0.0001
6902.5 22.3031 0.0026 0.0111 0.0228 0.0000 0.0000
6903.0 20.0020 0.0053 0.0061 0.0155 0.0000 0.0000
6903.5 21.5065 0.0027 0.0075 0.0204 0.0000 0.0000
6904.0 24.3387 0.0000 0.0032 0.0175 0.0000 0.0000
6904.5 29.2992 0.0039 0.0072 0.0237 0.0000 0.0001
6905.0 31.4188 0.0020 0.0091 0.0289 0.0000 0.0000