I have a script. Here is a piece of code.

foreach($products AS $key=>$product){ $row = $key++; $photo_txt = ''; foreach($product['photos'] AS $photo){ $photo_txt .= $photo ."|". PHP_EOL; } $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A'.$row, $product['title']) ->setCellValue('B'.$row, $product['price']) ->setCellValue('C'.$row, $product['description']) ->setCellValue('D'.$row, $product['photo']) ->setCellValue('E'.$row, $product['photo']."|". $photo_txt) ->setCellValue('F'.$row, $product['sex']); } 

Actually, in column C, you need to add values, as in column E. (in column E, photos are added one by one if there are a lot of them). I want to change the line C and make it like this

 ->setCellValue('C'.$row, $product['description']."||". $description_txt) 

But I do not know how to add one more condition in foreach ....

  • one
    you can replace the loop with $photo_txt = implode('|', $product['photos']); - teran

0