Creating an array that loops out on the frontend - Don't Repeat Yourself?
Architecturally, I'm adverse to hard-coding HTML tags within PHP code. If, for example, you wanted to migrate the code base from PHP to another language (Java, Python, Ruby, Go, Haxe,  whatever) then you have to rewrite both the logic (PHP) and the presentation (PHP) code.

Consider decoupling the logic from the presentation so that you can change how the data appears without having to change how the data is retrieved. This simplifies switching implementation languages and opens the possibility to create different views of the same data for different devices.

To do this, you have to create an interface or contract between the logic and the system that renders the logic for the user. Fortunately, this is where XML excels.

Instead of hard-coding &lt;strong&gt;, you would create an XML document that represents the information you want to display. The XML document becomes the contract between the logic and presentation, which allows both to vary independently. Once the XML document is in place you can pass it to an XSLT Processor to generate the desired HTML content.

This offers the following advantages:


Decoupled. The presentation logic moves to XSLT, completely decoupling it from the PHP code.
Migration. Migrating from PHP to another language means the presentation logic need not change.
Devices. It becomes trivial to change the presentation for different devices (use a new template).
DRY. With display logic in a central location, duplicated code is easier to eliminate.
Databases. Many databases now allow constructing XML documents within stored procedures, eliminating complex code readily expressed in SQL.
SaaS. It simplifies creating a SaaS API -- transforming XML to JSON is fairly easy a solved problem.


This has the following disadvantages:


Effort. Migrating to an XML/XSLT solution for presentation takes a lot of work.
Knowledge. Introduces a second programming language (XSLT) into the software.
Developers. Far fewer developers know XSLT than PHP.
XSLT 1.0. Using PHP, the processor is limited to XSLT v1.0 (many great features are in XSLT 2.0).
Bugs. The XSLT Processor has some pesky known bugs, which could be avoided by moving to XSLT 2.0 with the SAXON processor.