I am trying to display lines from a file based on a date range (ex: get today + next 7 days based on date field). I'm not familiar with PHP. I have the following to read the file and create an array from the contents:
$txt_file = file_get_contents('shipping_dates.txt');
$rows = explode("\n", $txt_file);
array_shift($rows);
foreach($rows as $row => $data)
{
//get row data
$row_data = explode(',', $data);
$info[$row]['Order_Date'] = $row_data[0];
$info[$row]['Free_Shipping'] = $row_data[1];
$info[$row]['Rush_Order'] = $row_data[2];
//display data
echo 'Row ' . $row . ' Order_Date: ' . $info[$row]['Order_Date'] . '<br />';
echo 'Row ' . $row . ' Free_Shipping: ' . $info[$row]['Free_Shipping'] . '<br />';
echo 'Row ' . $row . ' Rush_Order: ' . $info[$row]['Rush_Order'] . '<br />';
}
This works great - Now I need to grab the individual lines based on a date range and display only the lines within the range only, not the entire contents for each of these 3 options.
$info[$row]['Order_Date']? Is that date in any normal format, or a string, or... ? You may want to looke into DateTime object, and thecreateFromFormatfunction to then do date operations with it. php.net/manual/en/datetime.createfromformat.php