Answer the question
In order to leave comments, you need to log in
Mustache - iterate over an associative array
Data
$data = array(
'items' => array('елемент1', 'елемент2', 'елемент3', 'елемент4')
);
<ul>
{{#items}}
<li> {{.}}
{{/items}}
<ul>
<ul>
<li> елемент1
<li> елемент2
<li> елемент3
<li> елемент4
<ul>
$data = array(
'items' => array(
'el1' => 'елемент1',
'el2' => 'елемент2',
'el3' => 'елемент3',
'el4' => 'елемент4',
)
);
Answer the question
In order to leave comments, you need to log in
I don't know PHP very well. Therefore, I will show you JSON data.
$data = array(
'items' => array(
'el1' => 'елемент1',
'el2' => 'елемент2',
'el3' => 'елемент3',
'el4' => 'елемент4',
)
);
{
"items": {
"el1":"element1", "el2":"element2", "el3":"element3", "el4":"element4"
}
}
<ul>
{{#items}}
{{#el1}}<li> {{el1}}{{/el1}}
{{#el2}}<li> {{el2}}{{/el2}}
{{#el3}}<li> {{el3}}{{/el3}}
{{#el4}}<li> {{el4}}{{/el4}}
{{/items}}
<ul>
{
"items": [
{"el":"element1"}, {"el":"element2"}, {"el3":"element3"}, {"el4":"element4"}
]
}
<ul>
{{#items}}
{{#el}}<li> {{el}}{{/el}}
{{/items}}
<ul>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question