I have this code:
if(!strstr($value, '<p>')){...}
This outputs data from a database to an excel file excluding any fields that contain <p>
.
I would also like to exclude fields that contains </script>
Ive tried these two code snippets without success:
if((!strstr($value, '<p>')) and (!strstr($value, '</script>')))
And:
if(!strstr($value, '<p>', '</script>'))
Basically my question is how can I exclude both <p>
and </scrpit>
from my excel file?
You can use regural expression and preg_match function for this one:
if(!preg_match("/(<p>|<\/script>)/", $value)) {
// Do your magic!
}
You can read more about preg_match here: PHP preg_match And if you have problems with regular expressions, check out this example: example and play around with it to get a hold of regular expressions.
And as far as I can see, your logic should work just fine. Maybe your $value variables hold wrong data. Anyway, you have something to get you going.
Hope this helps!