I hope someone can help me here, as I cannot figure out for the life of me on how to do this.
I have a csv file with data in it like so:
Stock#,Year,Make,Model,Engine,Transmission,Color,Mileage,VIN,Asking,Equipment,,,,,,,,,,,,,,,,,,,,,,,,,
401883,2003,Mazda Truck,MPV LX Minivan 4D,V6 3.0 Liter,Automatic,Lt. Blue,19886,JM3LW28J330353753,20795,Front Wheel Drive,Power Sliding Doors,7 Passenger,Air Conditioning,Rear Air,Power Steering,Power Windows,Power Door Locks,Tilt Wheel,Cruise Control,AM/FM Stereo,Single Compact Disc,Dual Front Air Bags,ABS (4-Wheel),Quad Seating,Privacy Glass,Alloy Wheels,,,,,,,,,
401881,2001,Ford Truck,Expedition Sport Utility 4D,V8 5.4 Liter,Automatic,Blue,54742,1FMRU17L71LA17357,22995,2 Wheel Drive,Eddie Bauer,Air Conditioning,Rear Air,Power Steering,Power Windows,Power Door Locks,Tilt Wheel,Cruise Control,AM/FM Stereo,Cassette,Multi Compact Disc,Dual Front Air Bags,ABS (4-Wheel),Leather,Dual Power Seats,Third Seat,Roof Rack,Privacy Glass,Running Boards,Towing Pkg,Two-Tone Paint,Premium Wheels,,,
On each line in position 10 I have the equiptment and so on util the end of the line. What I am trying to do is get all the equiptment for each line in the variable $equiptment. Here is what I have so far:
Code: Select all
// Get file
$lines = file ('./data/inventorynew.csv');
// Loop through file
foreach ($lines as $line_num => $line) {
$rows = list($stock,$year,$make,$model,$engine,$trans,$color,$miles,$vin,$price,$equipt) = split (",", $line);
$numrows = count($rows)."<br>"; // Get number of columns in line
}I tried this and it does not work right:
Code: Select all
$lines = file ('./data/inventorynew.csv');
foreach ($lines as $line_num => $line) {
$rows = list($stock,$year,$make,$model,$engine,$trans,$color,$miles,$vin,$price,$equipt) = split (",", $line);
$numrows = count($rows);
$i = 10;
while ($i <= $numrows) {
$equiptment .= $equipt;
$i++;
}
}
echo $equiptment;Thanks in advance!
Ray