Tell me how to edit a cell or column in a csv file? using php
There is a csv file with 6 lines say
id, hiring, price, quantity, sum
1,Π»ΠΎΠΆΠΊΠ°,34,2,32 2,ΠΊΡΡΠΆΠΊΠ°,23,4,66 3,ΡΠ°ΡΠ΅Π»ΠΊΠ°,45,6,352 4.Π²ΠΈΠ»ΠΊΠ°,21,3,235 let's say how to overwrite the bag 34 * 2 =
` $cart = file("data/file.csv"); $total_sum = 0; $summa = 0; foreach($cart as $elem => $line) { if(!strripos($line, ",")) continue; $elem = explode(",",$line); $summa += $elem[2]; echo '<tr> <td>'.$elem[1].'</td> <td>'.$elem[2].'</td> <td>'.$elem[3].'</td> <td>'.$elem[2] * $elem[3].'</td> <td>'.$elem[4].'</td> </tr>'; } echo '<tr><td colspan="3" >'.$summa.'</td> <td>'.$total_sum.'</td><td></td></tr>'; `