0

I need to change a bunch of HTML elements to just show values instead of showing the input with the value... With normal input's it's a breeze, but with the radio buttons it's proving to be quite a bit more difficult. And I assume checkboxes will have the same issue since they both use multi-line with php loops...

Please Note: $array is an existing array with the field's values in it

Is it possible to use regex to change the below code:

<tr>
            <td colspan="1" class="title_td">The Column's Title Is Shown Here</td>
            <td colspan="3" class="input_td">
                <fieldset id="radio_group_name">
                    <?php
                        foreach ($radio_group as $option){
                            ?>
                                <label><input type="radio" value="<?php echo $option; ?>" name="radio_group_name" <?php echo ($array->radio_group_name==$option ? "checked='checked'" : ""); ?>> <?php echo $option; ?></label>
                            <?php
                        }
                    ?>
                </fieldset>
            </td>
        </tr>

And convert it into:

<tr>
                <td colspan="1" class="title_td">The Column's Title Is Shown Here</td>
                <td colspan="3" class="input_td"><?php echo $array->radio_group_name; ?></td>
            </tr>

I used http://buildregex.com/ to build a regex command and used https://regexr.com/ to test it, but RegExr says that there is no match when I use something like /<fieldset id="(?:.*)(?:type\=\"radio\")(?:.*)(?:\<\?php)/gim and other phrases...

When I remove fieldset id=" from the regex it pick's up the input, aswell as when I remove the below line's info it does pickup the fieldset id=" line, but I can't get it to work with the 2 together, think it may be because it's split accross a couple of lines...

Does anybody know of a solution?

Marcel
  • 752
  • 13
  • 26

0 Answers0