I have array $DATA as below
{
"LSP": "EXB",
"AWB": "8421604",
"SCANS": [
{
"SCAN_TIME": "2019-07-17 20:05:00",
"SCAN_STATUS": "Uploaded",
"SCAN_CODE": "001",
"SCAN_LOCATION": "DLH"
},
{
"SCAN_TIME": "2019-07-18 15:52:00",
"SCAN_STATUS": "Picked Up",
"SCAN_CODE": "0011",
"SCAN_LOCATION": "DLH"
},
{
"SCAN_TIME": "2019-07-19 00:22:00",
"SCAN_STATUS": "Scanned",
"SCAN_CODE": "003",
"SCAN_LOCATION": "GAX"
}
]
}
$CODES = array("0011","003");
Now I want to search the SCAN_CODE values in $CODES from $DATA
So using array_search the same returns an error. My current code to get KEY is
$SEARCH_KEY = array_search($CODES,array_column($DATA,"SCAN_CODE"));
$SEARCH_KEY returns
false
My requirement is to get the first INDEX VALUE even if there are multiple INDEXES with same VALUE for SCAN_CODE and I guess array_search returns only the first instance.
$DATAis not possible to use array_column on. Use it on$DATA['SCANS']adn it should work. And please post a working json.