Muhammad Arif Muhammad Arif - 6 months ago 3x
HTML Question

How to remove html tag in php?

I want to remove this code when my cmd value=compare,how i do this?

Here is my code:

<h1 style="margin-top:24px;"><?=ucfirst($_GET['page5'])?><? if($_POST['mode']=='test' || $_GET['mode']=='test') { print " (Test Mode)"; } ?></h1>

if($_GET['cmd']=='compare' && !$_POST)

I used this code:

$dom = str_get_html($html);

// ...or construct dom from file/url
$dom = file_get_html($path);

// strip h1 tags (and their content)
foreach ($dom->find('h1') as $node) {
$node->outertext = '';

How i remove above code when cmd=compare


(If I have well understood your question.) I cannot check the exact syntax and php is not my main language, but that's something I already done: I would write like this

if($_GET['cmd']=='compare' && !$_POST)
    [here comes the optional HTML code, may inclu php parts et]

So if the condition is not met, the code simply won't be displayed.