S
S
smoklew2016-02-29 22:18:24
PHP
smoklew, 2016-02-29 22:18:24

How to make each object in a span?

Hello everyone, I'm not strong in php, so I would like to hear some advice ...
There is a code:

<?php if ($options) { ?>
    <div class="options">
    <?php foreach ($options as $option) { ?>
      

      <?php if ($option['type'] == 'radio') { ?>

        <div class="options_color">
          <h2 class="heading_descriptions">
            <?php echo $option['name']; ?>:
          </h2>

          <span class="text_descriptions" >
            <?php foreach ($option['option_value'] as $option_value) { ?>

              <input type="radio"/>
              <label for="option-value-<?php echo $option_value['product_option_value_id']; ?>">
                <?php echo $option_value['name']; ?>
              </label>
              
          </span>

        </div>
            <?php } ?>
      <?php } ?>
    </div>
    <?php } ?>
  <?php } ?>

As a result, 3 options are obtained, but only the first one is wrapped in a tag; the rest go beyond its limits, I need each option to be wrapped in this tag.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tvelforce, 2016-02-29
@smoklew

Like so:

<?php if ($options) { ?>
    <div class="options">
    <?php foreach ($options as $option) { ?>
      

      <?php if ($option['type'] == 'radio') { ?>

        <div class="options_color">
          <h2 class="heading_descriptions">
            <?php echo $option['name']; ?>:
          </h2>

          
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <span class="text_descriptions" >
              <input type="radio"/>
              <label for="option-value-<?php echo $option_value['product_option_value_id']; ?>">
                <?php echo $option_value['name']; ?>
              </label>
              
          	</span>
            <?php } ?>
        </div>
            
      <?php } ?>
    </div>
    <?php } ?>
  <?php } ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question