how to update all keys an object by getting an array witch have keys that we want
Example :
const data = {
0 : {text : 'hello'},
1 : {text : 'hi'},
2 : {text : 'hay!'}
}
function arrayCombine(keys , values){
...logics
}
console.log(arrayCombine([10 , 20 , 37] , data));
// resault
{
10 : {text : 'hello'},
20 : {text : 'hi'},
37 : {text : 'hay!'}
}
This function gets an array and an object then performs an operation on the object and change all the keys of the object to that array’s element.
In the php we have a built-in function witch is called array_combine
.
2
Answers
If I understood correctly, below logic should works