I should not have been looping at all. This (not optimized) code fixes all issues and adds Difficulty.
add_shortcode('get_run', 'get_run_status');
function get_run_status($atts) {
$atts = shortcode_atts(array(
'run' => '',
), $atts);
$run_output="";
$diff_output="";
$found_day = false;
$found_night = false;
$run_atts = sanitize_text_field($atts['run']);
$run_query = get_field($run_atts);
if($run_query):
$run_status = $run_query['status'];
$run_difficulty = $run_query['difficulty'];
endif;
foreach ($run_status as $status_value) {
if (strpos($status_value, 'Snowmaking') !== false) {
$html_output="<img src="/wp-content/uploads/2024/03/Snowflake.png" alt="Snowmaking" />" . $html_output;
} elseif (strpos($status_value, 'Day') !== false) {
$html_output .= '<img src="/wp-content/uploads/2024/03/Circle-Checkmark.png" alt="Open Day" />';
$found_day = true;
} elseif (strpos($status_value, 'Night') !== false) {
$html_output .= '<img src="/wp-content/uploads/2024/03/Circle-Checkmark.png" alt="Open Night" />';
$found_night = true;
}
}
if ($run_difficulty === 'Easiest') {
$diff_output="<img src="/wp-content/uploads/2024/03/Green-Circle.png" alt="Easiest" />";
} elseif ($run_difficulty === 'Intermediate') {
$diff_output .= '<img src="/wp-content/uploads/2024/03/Blue-Square.png" alt="Difficult" />';
} elseif ($run_difficulty === 'More Difficult') {
$diff_output .= '<img src="/wp-content/uploads/2024/03/Black-Diamond.png" alt="More Difficult" />';
} elseif ($run_difficulty === 'Most Difficult') {
$diff_output .= '<img src="/wp-content/uploads/2024/03/Double-Black.png" alt="Most Difficult" />';
} elseif ($run_difficulty === 'Freestyle Terrain') {
$diff_output .= '<img src="/wp-content/uploads/2024/03/M-Circle.png" alt="Freestyle Terrain" />';
}
if (!$found_day) {
$html_output .= '<img src="/wp-content/uploads/2024/03/Red-X.png" alt="Closed" />';
}
if (!$found_night) {
$html_output .= '<img src="/wp-content/uploads/2024/03/Red-X.png" alt="Closed" />';
}
$html_output="<div class="run-row">" . $diff_output . '<div class="run-name">' . esc_html($run_atts) . '</div>' . $html_output . '</div>';
return $html_output;
}