Results Reporting / Checking with Multiple Results in For Loop
In case there is any chance to use a template engine, then you should prepare your data first

$obj = drupal_json_decode($result);
$output = [];
foreach($obj as $row){
    if(!$value["IsArchived"] &amp;&amp; !preg_match("/^123 ABC/", $value["ProjectName"])){
        $row['CommentStart'] = _abc_date($value["CommentStart"]);
        $row['CommentEnd'] = _abc_date($value["CommentEnd"]);
        $output[] = $row;
    } 
}


and then output it (an exampe is using Twig template engine but the logic would be the same even with raw PHP)

{% for value in output %}
    &lt;li class="list-group-item"&gt;
        &lt;strong&gt;{{ value["ProjectName"]}}&lt;/strong&gt;
        ({{ value["CommentStart"] }} - {{ value["CommentEnd"] }})
        {% if lrnmore %}
            | &lt;a href="CommentInput?project= {{ value["ProjectNumber"] }}"&gt;
                 {{ lrnmore }}
              &lt;/a&gt;
        {% endif %} 
        | &lt;a href="ReadingRoom?project={{ value["ProjectNumber"] }}"&gt;
            View Comments
        &lt;/a&gt;&lt;br/&gt;
        &lt;ul&gt;&lt;li&gt; {{ value["Description"] }}&lt;/li&gt;&lt;/ul&gt;
    &lt;/li&gt;
{% endfor %}
{% if not output %}
    &lt;li class="list-group-item"&gt;No Records to Display&lt;/li&gt;
{% endif %}


this way you will have a clear separation between the business logic and display logic and as a bonus you will have HTML which is readable and maintainable.