There is a line $this->lists['categories'] , which contains a select tag, which in turn contains a list of categories. So this select has the following form already on the page <select id="catid" name="catid"> <option value="0" selected="selected">- Выберите категорию -</option></select>
Well, then a list of categories, so I need to set the class this select . I try through preg_replace() as follows:
<?php $arr=preg_replace("<select>", "select class='selectpicker' data-live-search='true'", $this->lists['categories']) ?> <?php echo $arr; ?> It seems to replace, but also replaces the selected attribute (i.e., cuts it to select and ed ). Tell me how to avoid this? Maybe there is a regular expression for such a case. Thank.