cart.txt (tab delimated)
guiburi PID001 KARLSTAD Sofa 2348 2 4696
guiburi PID002 BESTA Cabinet 1656 32 52992
guiburi PID009 PAX Wordrobe 1794 2 3588
$pname = trim($_GET['pname']);
pname is sent from a another file using url and it used to match with the 3rd colum of the cart file and then delete the line.write back to the same file
ive tried many ways but no luck. any help? thanks
Are you using fgetcsv? If so it would be a simple matter of looping though the resulting array.
The general principal would be as follows
1) Read the file with file_get_contents
2) Get the separate lines in an array using explode by "\
", let's call this $lines
3) For each of those lines
3a) explode the line on "\ "
3b) Check if the third element of the result of 3a equals $pname
3c) If it does, remove the element from $lines
4) implode the array $lines with "\
5) Write the data back to the file using file_put_contents
This topic is now closed. New replies are no longer allowed.