Answers.Body: <p>Not sure if you really wanted dynamic variable names like <code>imgurl1</code> or not, but something like this?</p>
  
  <pre><code>&lt;div class="row"&gt;
  {% for entry in entries %}
      {% set loopIndex = loop.index %}
      &lt;div&gt;&lt;p&gt;text{{loopIndex}}&lt;/p&gt;&lt;img src="{{ _context['imgurl' ~ loopIndex] }}" /&gt;&lt;/div&gt;
      {% if loopIndex is divisible by(3) %}
          {% if not loop.last %}
              &lt;/div&gt;
              &lt;div class="row"&gt;
          {% endif %}
      {% endif %}
  {% endfor %}
  &lt;/div&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-06T07:47:49.920Z
Answers.Text: yes, it displays the correct HTML structure, thank you very much for your help.
Answers.UserDisplayName: Cosmin Ciolacu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-06T04:29:06.377Z
Answers.LastActivityDate: 2020-05-06T04:29:06.377Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have an Matrix field and I want to extract data in the following HTML structure:</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div&gt;&lt;p&gt;text1&lt;/p&gt;&lt;img src="{{imgurl1}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text2&lt;/p&gt;&lt;img src="{{imgurl2}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text3&lt;/p&gt;&lt;img src="{{imgurl3}}" /&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row"&gt;
    &lt;div&gt;&lt;p&gt;text4&lt;/p&gt;&lt;img src="{{imgurl4}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text5&lt;/p&gt;&lt;img src="{{imgurl5}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text6&lt;/p&gt;&lt;img src="{{imgurl6}}" /&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and this is my twig code for retrieving data from craft:</p>
  
  <pre><code>
  {% for entry in entries %}
    {% if loop.index is divisible by(3) %}
       &lt;div class="row"&gt;
    &lt;div&gt;&lt;p&gt;text4&lt;/p&gt;&lt;img src="{{imgurl4}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text5&lt;/p&gt;&lt;img src="{{imgurl5}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text6&lt;/p&gt;&lt;img src="{{imgurl6}}" /&gt;&lt;/div&gt;
  &lt;/div&gt;
  {% else %}
   &lt;div&gt;&lt;p&gt;text4&lt;/p&gt;&lt;img src="{{imgurl4}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text5&lt;/p&gt;&lt;img src="{{imgurl5}}" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;p&gt;text6&lt;/p&gt;&lt;img src="{{imgurl6}}" /&gt;&lt;/div&gt;
  {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>I want to output multiple browse with free divs
  I am new to Craft and I will appreciate any help, thanks!</p>
  
Tags: <templating>
Title: Templating data in HTML
ThreadText: # Templating data in HTML
  
  (Asked by: username_0 on 2020-05-05)
  
  I have an Matrix field and I want to extract data in the following HTML structure:
  
  ```
  <div class="row">
    <div><p>text1</p><img src="{{imgurl1}}" /></div>
    <div><p>text2</p><img src="{{imgurl2}}" /></div>
    <div><p>text3</p><img src="{{imgurl3}}" /></div>
  </div>
  <div class="row">
    <div><p>text4</p><img src="{{imgurl4}}" /></div>
    <div><p>text5</p><img src="{{imgurl5}}" /></div>
    <div><p>text6</p><img src="{{imgurl6}}" /></div>
  </div>
  
  ```
  
  and this is my twig code for retrieving data from craft:
  
  ```
  
  {% for entry in entries %}
    {% if loop.index is divisible by(3) %}
       <div class="row">
    <div><p>text4</p><img src="{{imgurl4}}" /></div>
    <div><p>text5</p><img src="{{imgurl5}}" /></div>
    <div><p>text6</p><img src="{{imgurl6}}" /></div>
  </div>
  {% else %}
   <div><p>text4</p><img src="{{imgurl4}}" /></div>
    <div><p>text5</p><img src="{{imgurl5}}" /></div>
    <div><p>text6</p><img src="{{imgurl6}}" /></div>
  {% endif %}
  {% endfor %}
  
  ```
  
  I want to output multiple browse with free divs
  I am new to Craft and I will appreciate any help, thanks!
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-05-06. Score: 1 | Accepted answer
  
  Not sure if you really wanted dynamic variable names like `imgurl1` or not, but something like this?
  
  ```
  <div class="row">
  {% for entry in entries %}
      {% set loopIndex = loop.index %}
      <div><p>text{{loopIndex}}</p><img src="{{ _context['imgurl' ~ loopIndex] }}" /></div>
      {% if loopIndex is divisible by(3) %}
          {% if not loop.last %}
              </div>
              <div class="row">
          {% endif %}
      {% endif %}
  {% endfor %}
  </div>
  
  ```
  
  > **Comments:**
  > **username_0**: yes, it displays the correct HTML structure, thank you very much for your help.  
  
  ---
  
  