So I am new to php and I am writing a script to take a time stamp in the form of "January 23, 2014 at 11:01PM" and break it into a multi-dimensional array with elements for month, date, year, hour, and minutes. Here is my code:
$raw_data= array("January 20, 1993 at 10:20PM", "September 6, 1991 at 6:23PM");
var_dump($raw_data);
$num_dates= count($raw_data);
//Step 1: break content into month, day, year, hour, and minutes
for ($i=0; $i=($num_dates-1); $i++) {
$partial_data = implode(preg_split("/[A-Z]{2}/", $raw_data[$i]));
$broken_data[$i] = preg_split("/[s,:]/", $partial_data);
unset($broken_data[$i][2]);
unset($broken_data[$i][3]);
}
For some reason, when I run this in the terminal it seems to be an infinite loop. I tested the code inside the for-loop on a one-dimensional array, and the output was what I expected, so I am pretty sure my problem is because I don't know how to format a for loop in php. Does anyone see an obvious beginner mistake?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…