Forum Moderators: coopster

Message Too Old, No Replies

Splitting up a list of years

I'm stuck.

         

ScottM

10:22 pm on Sep 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been able to muck my way through numerous little scripts, but I'm having problems working through this one.

I have a csv file and wish to split out seperate years for each line.

For example:

widget A,1966-2003,$6.00

is a single entry (of many).

What I want to do is split ($row[1]) into

widget A 1966 $6.00
widget A 1967 $6.00
widget A 1968 $6.00
.....
widget a 2003 $6.00

I just can't find the needed function to do this.

I believe I could split the years out into 1966 and 2003 and do a count or a range function, but is there any easier way?

Any ideas?

jatar_k

11:00 pm on Sep 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$yrs = split ("-",$row[1]);
for ($i=$yrs[0];$i <= $yrs[1];$i++) {
echo "<br>$row[0] $i $row[2]";
}

that's pretty short

ScottM

11:46 am on Oct 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks!

That will work just fine!