I have CSV text thats stored in the session array as csv. The lines are terminated by ### and fields terminated by %%.
I also have a line number of a line within that array which is CID, or the line which i want to clone.
I need to find that line within the csv array, splice it, and then update the session variable with the spliced array.
$data = $_SESSION['csv'];
$cid = $_POST['cid'];
$csvpre = explode("###", $data);
foreach ( $csvpre AS $key => $value){
$info = explode("%%", $value);
if($info[0] == "$cid"){
array_splice($csvpre, $cid, 0, $info);
}
}
I dont think im doing it right, im on no sleep and this is getting confusing.
the goal is to let the user select which line to clone, and then perform this function, and have that line cloned in the csv session variable