Hi, I want to exclude from appearing the text inside <ul></ul> tags from a string with PHP. is this possible? how i can do it? thanks in advance.
Here you go <?php $string = 'This is a test text. <ul><li>item 1</li><li>item 2</li><li>item 3</li><li>item 4</li></ul> There shouldn\'t be any lists anymore.'; $pattern = '/(<ul>.*?<\/ul>)/i'; $replacement = ''; echo preg_replace($pattern, $replacement, $string); ?> PHP:
strip_tags removes all the tags, but not the text between any specific tags. Use preg_replace or create the string as 2 (or 3) separate strings, build the list and you still have the text not within the <ul></ul> as strings.