Closed seth-shaw-unlv closed 2 years ago
This is a bad assumption on my part that if the first array (in a set of arrays) has an element with key @id
then they all would. Instead I probably need to check for the key and if it doesn't exist then include that value too.
@whikloj, something like this?
private static function deduplicateArrayOfIds(array $array): array {
$temp_array = [];
foreach ($array as $val) {
if (! array_key_exists('@id', $val) || array_search($val['@id'], array_column($temp_array, '@id')) === FALSE) {
$temp_array[] = $val;
}
}
return $temp_array;
}
I've started getting the following errors popping up in my error queue:
I'm not sure what it is complaining about, because none of the referenced objects in the JSON-LD that triggered it are missing an
@id
property: