php


Detecting if a group of words was mentioned


I would like to know if there's anyway of detecting if a group of words was mentioned in a string with PHP. Let's suppose that it's allowed to say "assault" but "assault+rifle" isn't. So...
"I saw an assault" shouldn't be detected
"I bought an assault rifle" should
"I assaulted a bank with my rifle" also should
A common way would be to split the input string (i.e "assault+rifle") by "+"s, then for each of those, check if it is in the original text.
// Assuming:
$text;
$words;
// Iterating through the splitted $words
foreach(explode("+", $words) as &$word) {
// Checking if the text contains our word
if (strpos($text, $word) === false)) {
die("Allowed");
}
}
echo "Not Allowed";

Related Links

Issues with getting output from JOIN query
Getting Started with cakephp-file-storage quickstart guide
Didn't update the database automatically after computation
How to display wordpress database values in table the right way?
getting Fatal error: Call to a member function _query() on a non-object in C:\wamp\www\quotes\paginator.php on line 33 [duplicate]
Return a result from an sql query
How to avoid one query's match id with another query
Make bootstrap link active in php
How to retrieve a value sent by a controller in textbox?
Password fields won't validate properly PHP
MySQL updates some records but not all (using PHP)
.htaccess help - Codeigniter
php request authorization from remote server
Symfony2 - Doctrine returns big unexcepted object
Generate Background for Each Post With Wordpress Thumbnail
Oracle SQL PHP INSERT speed optimization? [closed]

Categories

HOME
android-studio
macos-sierra
swi-prolog
transactions
windows-10
google-sheets-query
tfs2015
firebase-database
wine
cqrs
sap-fiori
multi-step
google-awareness
pushdown-automaton
dhcp
supervisord
fosuserbundle
rpmbuild
jaspersoft-studio
boomi
xsl-fo
significance
activeadmin
kaggle
liferay-6.2
restier
managed-c++
webviewclient
fstar
bonita
sfml
netbios
python-2.x
rspec-rails
appcode
microsoft-certifications
om-next
mongoengine
payeezy
apptentive
directfb
rails-postgresql
bluemixtools
forms-authentication
task-parallel-library
contactless-smartcard
notesview
virtual-memory
destroy
flume-twitter
qvtkwidget
knockout-2.0
winston
aurelia-fetch-client
nslayoutconstraint
http-basic-authentication
connect-direct
word-2016
instafeedjs
ndk-build
system.web.optimization
clp
nunit-console
dpkg
node-glob
fdt
swiffy
univocity
ioctl
cortana
phpquery
variable-length-array
html.actionlink
openshift-cartridge
auto-generate
dynamics-ax-2012-r2
ocmockito
gflags
mojo
spring-social-linkedin
profiles
frontbase
boinc
google-code-prettify
chartfx
statechart
oscilloscope
cyrillic
office-app
multiscaleimage
spark-view-engine
arrow
server-name
pageheap
navigationcontroller
qtextbrowser
motodev-studio
server-variables
getopts
firefly-mv
office-automation
uninstaller
ixmldomdocument
j2mepolish
community-server

Resources

Encrypt Message