Login
Remember
Register
PHPOnlineSupport
Questions
Unanswered
Tags
Categories
Ask a Question
Ask a Question
php find exact match in string?
0
votes
8.9k
views
asked
Mar 5, 2018
in
General
by
mithun
(
1.3k
points)
php find exact match in string. not just contain words?
ie check if exact "India" inside a string, should not consider "Indiana" or something similiar.
How would you do that?
compare
string
php
contains
Your comment on this question:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
1
Answer
0
votes
answered
Mar 5, 2018
by
Jonat
Use the regex
$wildcard = "india";
$string = 'Bala Ji Karnal, India';
if (preg_match("/\b".$wildcard."\b/i", $string))
{
echo "Got it!";
}
else
{
echo "No match found!";
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Related questions
+2
votes
2
answers
10.8k
views
Replace all last occurrence of characters of string
asked
Jun 3, 2016
in
General
by
Neethu
string
replace
php
0
votes
1
answer
994
views
What is PEAR in PHP?
asked
Oct 29, 2021
in
General
by
anonymous
php
0
votes
2
answers
12.1k
views
In PHP using Ternary Operator without the Else statement
asked
Jul 31, 2017
in
General
by
Fahad
php
ternary
if
else
0
votes
1
answer
1.1k
views
php get text after character
asked
Jan 23, 2022
in
General
by
Sarath
php
0
votes
1
answer
1.1k
views
What are the different types of PHP variables?
asked
Oct 29, 2021
in
General
by
anonymous
php
0
votes
1
answer
1.1k
views
How to solve warning error on php?
asked
Oct 4, 2021
in
General
by
Tester Testee
(
220
points)
php
All categories
General
(56)
CMS
(21)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Databases
(5)
Categories
All categories
General
(56)
CMS
(21)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Databases
(5)
Most popular tags
magento
php
wordpress
wp
laravel
category
database
module
product
arduino
kohana
js
jquery
admin
date
url
sing
birds
json
javascript
cms
cache
error
configurable
love
mac
xbee
serial1
serial
seo
encrypt
recaptha
phalcon
truncate
fishpig
include
backend
function
email
plugin
post
arduinojson
popup
mongodb
security
migrate
editor
decrypt
python
iot
map
shipping
password
core
log
mage
pear
string
replace
extension
import
php7
form
order
day
google
image
youtube
https
http
customer
syntaxerror
datatables
nested
x-ctu
xctu
pan-id
mesh
coordinator
esp
baud
esp8266
esp32
path-issue
site-links
adblocker
qr-code
barcode
samsung
newsletter
feed
auto-numbering-column
datatable
admin-bar
adminbar
toolbar
address16
address64
301
302
...