S
S
skyhitr2021-06-30 12:39:51
PHP
skyhitr, 2021-06-30 12:39:51

How to change text between html tags in php?

You need to remove the number before the name

<select name=" " id="speaker_152" class="postform">
    <option value="" selected="selected">Спикер</option>
    <option class="level-0" value="20">1 ФИО</option>
    <option class="level-0" value="21">2 ФИО</option>
    <option class="level-0" value="22">3 ФИО</option>
</select>


So far, everything has come to what it is, this is the removal of everything between the tags
$result = preg_replace('#(<option[^>]*>).*?(</option>)#', '$1$2', $html);
echo $result;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-06-30
@skyhitr

preg_replace('#<option[^>]*>\s*\K\d#', '', $html)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question