I'm looping in an array, filling it with data from a file. I'm trying to change the data from one cell to another and then leave the old cell empty. So far I was using this code and it worked:
$custom_array_price['b'] = $custom_array_price['c'];
unset($custom_array_price['c']);
But for this specific case it doesn't work. It deletes the data before it gets copied.
How do I make it work?
This is the code I'm trying to use now:
$custom_array_price['c'] = $custom_array_price['d'];
unset($custom_array_price['d']);
The loop looks like this:
foreach ( $custom_array_price as $custom_key => $custom_value ) {
$custom_value = utf8_encode($custom_value);
if ( $custom_key == 'a' ){
if ( $custom_value == "Fecha:" ){
if( count($recibos) > 0 ){
$recibos[$cont]['html'].= "</tr>";
$recibos[$cont]['html'].= "</table>";
$cont++;
$times = 0;
}
$recibos[$cont]['html'] = "<table>";
$recibos[$cont]['html'].= "<tr>";
}else{
$recibos[$cont]['html'].= "<tr>";
}
}
if ( $times <= 5 ){
$custom_array_price['b'] = $custom_array_price['c'];
$custom_array_price['c'] = $custom_array_price['d'];
unset($custom_array_price['d']);
}
if ( $custom_value == "Neto a Pagar:"){
$custom_array_price['l'] = $custom_array_price['k'];
unset($custom_array_price['k']);
}
if ( $custom_value == "A001"){
$custom_array_price['g'] = $custom_array_price['i'];
unset($custom_array_price['i']);
}
$recibos[$cont]['html'].= "<td>";
$recibos[$cont]['html'].= $custom_value;
$recibos[$cont]['html'].= "</td>";
}
$recibos[$cont]['html'].= "</tr>";
Another part of the code. Where the csv file is being read and the data is being copied:
$recibos = array();
foreach($data_rows_price as $key => $value){
$times++;
for($i = 0; $i < count($value); $i++){
if(array_key_exists('mapping'.$i,$ret_array)){
if($ret_array['mapping'.$i]!='add_custom'.$i){
$new_post[$ret_array['mapping'.$i]] = $value[$i];
}
else{
$new_post[$ret_array['textbox'.$i]] = $value[$i];
$custom_array_price[$ret_array['textbox'.$i]] = $value[$i];
}
}
}
for($inc = 0; $inc < count($value); $inc++){
foreach($keys_price as $k => $v){
if(array_key_exists($v,$new_post)){
$custom_array_price[$v] = $new_post[$v];
}
}
}