Skip to content
Advertisement

Extract equal values for multidimensional array in php

I have this problem. I have a multidimensional 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 each 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 array or all at once to a single variable. Please HELP!!!

Love V

Here is the code:

JavaScript

Advertisement

Answer

You’re overwritting your array on each iterations $recnumber = array($getarray);

I would rather follow this logic :

JavaScript

This outputs :

array(4) {
[0]=>
string(13) “record_id_003”
[1]=>
string(13) “record_id_006”
[2]=>
string(13) “record_id_008”
[3]=>
string(13) “record_id_011”
}

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement