Answer the question
In order to leave comments, you need to log in
Is it possible to write variables with keys in a string?
Hello. I need to collect the HTML code as a string and send it to the client. I need to fill this code with variables. The problem is that the variables are from an array and they all have keys. That is, I need to specify variables with keys in the line.
This does not work:
foreach ($orders['entries'] as $o) {
$htmlorder[] = "<td class='id'>$o['_id']</td>";
}
Answer the question
In order to leave comments, you need to log in
Wrap with curly braces
foreach ($orders['entries'] as $o) {
$htmlorder[] = "<td class='id'>{$o['_id']}</td>";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question