如何从php中的结果中获取json键名?

I want to the key or reference_id detail (as both are same value) when the art_ean value contains 400004471.

{
    "TD0000000000993": {
        "reference_id": "TD0000000000993",
        "art_ean": "400004481|,400004491|,400004471|"
    },
    "TD0000000000992": {
        "reference_id": "TD0000000000992",
        "art_ean": "400004482|,400004492|,400004472|"
    }
}

Your json is not valid. You should remove the last , on each object. You can use a list to have some more details https://jsonlint.com.

Here is what I believe that you want.

<?php

$data = '{
    "TD0000000000993": {
        "reference_id": "TD0000000000993",
        "art_ean": "400004481|,400004491|,400004471|"
    },
    "TD0000000000992": {
        "reference_id": "TD0000000000992",
        "art_ean": "400004482|,400004492|,400004472|"
    }
}';

$decodedData = \json_decode($data, true);

$result = array_column(
    array_filter($decodedData, function($data) {
        return false !== strpos($data['art_ean'], '400004471');
    }),
    'reference_id'
);