Title: Code Question About For Loops
Last modified: August 17, 2019

---

# Code Question About For Loops

 *  Resolved [joshuamadrid](https://wordpress.org/support/users/joshuamadrid/)
 * (@joshuamadrid)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/code-question-about-for-loops/)
 * I am Trying to write a for loop and allow the use of adding more to the block
   why is this erroring?
 *     ```
       <div id="<?php block_field('custom-id'); ?>" class="btn-group <?php block_field('custom-class'); ?>" role="group">
           <?php
           $BTN_NUM = block_value('number-buttons');
           for ($i = 0; $i < $BTN_NUM; $i++) {
               echo '<button href="' + block_field('button-url-' + $i ) + '" type="button" class="btn ' + block_field('button-type-' + $i ) + '">' ;
                   block_field('button-text-' + $i );
               echo '</button>' ;
           }
           ?>
       </div>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [joshuamadrid](https://wordpress.org/support/users/joshuamadrid/)
 * (@joshuamadrid)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/code-question-about-for-loops/#post-11841850)
 * Sorry discovered my mistake it was that + and a string was like adding 0 to a
   number so instead i needed a . not a +
 *  Plugin Author [Luke Carbis](https://wordpress.org/support/users/lukecarbis/)
 * (@lukecarbis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/code-question-about-for-loops/#post-11842246)
 * [@joshuamadrid](https://wordpress.org/support/users/joshuamadrid/) Glad you figured
   it out!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Code Question About For Loops’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/block-lab_5c34e8.svg)
 * [Block Lab](https://wordpress.org/plugins/block-lab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/block-lab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/block-lab/)
 * [Active Topics](https://wordpress.org/support/plugin/block-lab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/block-lab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/block-lab/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Luke Carbis](https://wordpress.org/support/users/lukecarbis/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/code-question-about-for-loops/#post-11842246)
 * Status: resolved