Add the search on the $category to display only array items that have details (as in details on the injury):
if (array_key_exists("details", $category)) {
foreach( $category as $index => $value ) {
$result[$index][$key]= $value;
echo "<li>" . $value . " </li>" ;
}
}