Data php in the HTML template. How to implement?

I have an array that outputs the names of the characters from the database:
while ($char_row = $char_table_result->fetchArray()) {
 $arrChartData[] = $char_row['name']; 
}

The maximum characters can be 5
I need to make so that in HTML you can insert something like the tag {CHAR 1} and he brought the name of the character $arrChartData[1];
And so for each number character: {CHAR: 1}, {CHAR-2}, etc.
How it can be implemented?
June 10th 19 at 16:51
2 answers
June 10th 19 at 16:53
Solution
so it is not necessary to do. no {CHAR 1}
just need the template to use php variables
The fact of the matter is, I do not want to use php code in the template. It's as TPL in DLE - nikita.Stracke commented on June 10th 19 at 16:56
if you don't want to use php in the template - use Smarty
and actually where is the desire and what is the reason?

phpfaq.ru/tech/tpl#delusions
www.php.su/articles/?cat=examples&page=014 - micheal commented on June 10th 19 at 16:59
The desire is from what you do not want to clutter up HTML with php code, because it is not only me work :3
There is a man, which PHP knows nothing and is afraid of anything to spoil
And for the material thank you! - nikita.Stracke commented on June 10th 19 at 17:02
let's again read the article. what you wrote is totally not true.
these articles are quite old, but very true - you're not the first trying to invent the "nizoralnizoral". I'm about 10 years ago did, too.

you are now in a completely harmful way - you yourself (or read somewhere) came up with stories about "stupid coder" and "don't want to clutter up HTML with php code".

PHP was created as a language that allows to do inclusions in HTML. According to this principle works in many templating frameworks. Just do not confuse the application logic in HTML nobody else can. And from display logic in HTML, with control structures and loops - NOT to LEAVE.

Is absolutely dead-end ideas to implement {CHAR 1} - it is enough to write in the template

Difference - no. But in the template you can use the logical structure of language. Without them - your templates - no templates. This is described in the second article. - micheal commented on June 10th 19 at 17:05
, hmmm... Perhaps you're right. Thank you! - nikita.Stracke commented on June 10th 19 at 17:08
there are people, which PHP knows nothing and is afraid of anything to spoil

Don't get close to the templates. - Jerad_Padbe commented on June 10th 19 at 17:11
June 10th 19 at 16:55
All use the code in the templates. Adding a new layer of abstraction type [CHAR-1], you just complicate your life.

Find more questions by tags PHP