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!