I want to rename the values of an array in php, change this array:
$value('valor1','valor2');
to this other:
$value('v1','v2');
I want to rename the values of an array in php, change this array:
$value('valor1','valor2');
to this other:
$value('v1','v2');
You can use array_replace to replace item values within the array:
<?php
$value = array('valor1', 'valor2');
//aquí reemplazas los valores del array!
$replacements = array(0 => 'v1', 1 => 'v2');
$final_array = array_replace($value, $replacements);
print_r($final_array);
?>
According to the previous script, we would initially:
Array
(
[0] => valor1
[1] => valor2
)
and replacing the values within the array with array_replace as final values:
Array
(
[0] => v1
[1] => v2
)
You can see the example here .