How search the output only -
if any DOM as below?
<p>-</p>
<p><span style="font-size: medium;">-</span></p>
Currently I just use the codes as below to find this output -
:
$input = `<p>-</p>`;
if($input == `<p>-</p>`):
return true;
else:
return false;
endif;
Any better ideas?
The accepted answer would not work for special cases like if the tag attribute values contains >-<
or if -
is not wrapped within the tags:
$input = '<span title="A valid title >-<">Should NOT match</span>';
$input = '<span>Should match</span>-';
Instead you could use strip_tags()
, which is not as efficient as strpos()
but would work for all cases:
return (strip_tags($input) === '-');
try
$input = `<p>-</p>`;
$input = `<p><span style="font-size: medium;">-</span></p>`;
$input = `<p><div>-</div>`;
if(strpos($input, '>-<')):
return true;
else:
return false;
endif;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With