new to PHP and just barely have a handle on arrays. can’t find a like example of what I’m trying to do here. VERY OVERWHELMED and in GREAT NEED of a gentle bash in the skull to put me on the right path please!
have things running numerically, but associative would be MUCH better, plus I need to learn.
so this combo works fine:
$weekdays_array = array();
while ($info = mysql_fetch_array($query_result))
{
$weekdays_array = array( $info[‘first_hit’],
$info[‘frequency’],
$info[‘weekday’]);
}
and here’s my attempt at the same but associative:
$weekdays_array = array();
while ($info = mysql_fetch_array($query_result))
{
$weekdays_array = array($details => array($info[‘first_hit’], $info[‘frequency’], $info[‘weekday’] ));
}
thanks for the input guys. but it was of no help as I did not explain things, sorry. what’s going on here is a dynamic situation - the values are always changing.
the top part of the routine runs once. it builds an array of records from a DB table. in the example posted there are 7 records in the array - one for each weekday. now the bottom part of the routine runs for each and every day of a calendar, checking the array to see what to do about the day currently being processed.
each record contains a:
weekday: the day of week we’re taking about, e.g. 5 (represents Thursdays); frequency: how often to flag this day, e.g. every 14th day;
and first_hit: the date to begin flagging these days, e.g. 2010-03-11.
like I said, things run fine as a numerically keyed array. but I think going associative would make things easier later on, when I start doing something with the data - like asking “is there a record in the array that applies to the day currently running?”.
could really use some direction here please. I’ve been staring at this code too long and am truly lost.
I want the former, thank you. but first things first - how do I change my array to associative. at this point I’m so confused I’m not sure if it’s 2D or 3D!