I was testing the function of Jack P. , in which, given a $arrOriginal
and a $arrRemover
it is possible to obtain a $arrNuevo
without the keys indicated $arrRemover
.
But, if I would also like to recover the values and keys eliminated with $arrRemovidos
in unset
, how could I do it? That is, have two arrays, one with the keys and values that are not in $arrRemover
and another with the keys and values that are in $arrRemover
.
I was looking if unset
had some opposite, but I found nothing.
Expressed in code would be:
$arrOriginal=
array(
array(
"Id"=> 1,
"Nombre"=> "Pedro",
"Ciudad"=> "Galilea"
),
array(
"Id"=> 2,
"Nombre"=> "Santiago",
"Ciudad"=> "Betsaida"
)
);
$arrRemover=array("Id","Nombre");
This is what the function does:
$arrNuevo=
array(
array(
"Ciudad"=> "Galilea"
),
array(
"Ciudad"=> "Betsaida"
)
);
This is what I would also like to obtain, but I do not know how to do it.
$arrRemovidos=
array(
array(
"Id"=> 1,
"Nombre"=> "Pedro"
),
array(
"Id"=> 2,
"Nombre"=> "Santiago"
)
);