I am trying to read each column from the third one to the 12th from a csv file and store all the data in an array. At this point I only get the last column: Here is my file:
Here is my code:
<?php
$in_file = 'gabriel-images-urls.csv';
$fd = fopen($in_file, "r");
$new_array[]= array();
$start_row = 2;
$i = 2;//define row count flag
while (($row = fgetcsv($fd)) !== FALSE) {
for ($col=3; $col<=11; $col++) {
$row[] = $row[$col];
if($i >= $start_row){
$url = $row[$col];
$url_name = basename($url);
$new_array[] = [$row[0], $row[1],$url_name];
}
$i++;
}
?>
So the idea is the variable $url_name to contain all the links from the above file with their basename and if it is posssible to be seperated with a comma in the array. Expected output:
Array
(
[0] => G5651407J
[1] => G5651407J
[2] => https://assets.suredone.com/683987/media-photos/g5651407j-gabriel-g56514-front-right-ultra-premium-twin-tube-strut-for-lexus-toyota-models.jpg, https://assets.suredone.com/683987/media-photos/cfc869-bendix-premium-copper-cfc869-front-brake-pad-set-for-chrysler-sebring-models-2.jpeg, https://assets.suredone.com/683987/media-photos/cfc869-bendix-premium-copper-cfc869-front-brake-pad-set-for-chrysler-sebring-models-3.jpeg
)
I want all of the links to be at the third element of the array, seperated with the comma.

$new_arraywithin thatforloop? That might end in eight new elements per CSV line