0
extract key from mutidimentional array in PHP
Hallo to the community, I have this problem. I have a multidimentional json array (don't ask - legacy code). I convert it to PHP array. I need to extract all KEYS that have EQUAL VALUE (in my case "666"). I need ach key to be assign to a SEPARATE variable. In my code i succeeded to fetch the keys but i can assign them only to another multidimensional array or to a single variable, but each overwrite the last value, no real use of this. Please HELP!!! Here is my code: https://code.sololearn.com/wiZe7xKA3u54 Love pap
5 ответов
0
I didn't understand the problem description. I see you have got to extracting the keys, but I don't understand what you want to do next
0
i want to extract ALL keys with equal value. now i just overwrite and i get only the last one as a value
0
record_id_0003, record_ids006, record_id_008, record_id_011 matches your filter criteria. But what do you want to overwrite? can you show me a little illustration of the desired output?
0
in real code i have a json array with 1k entries. i need to find the two or three entries among those 1k which are equal. i need a code with wich to assign each from this equal entries to aseparate variable so i can proceed those further. in code above i just assign the equal values to a single variable and thus they overwrite each other, so i get only the last key assigns
0
Do you want to save the key (record_id_***) or the values? I'm still unsure what you actually mean.
I think you need to save the matching rows into an array, but first, tell me what to save (key or value)
(Edit)
You might want to look into array_filter() to filter the source array.
https://www.w3schools.com/php/func_array_filter.asp