Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

string match in php

You could use regular expressions as its better for word matching compared to
strpos, as mentioned by other users. A strpos check for are will also return 
true for strings such as: fare, care, stare, etc. These unintended matches can 
simply be avoided in regular expression by using word boundaries.

A simple match for are could look something like this:

$a = 'How are you?';

if (preg_match('/are/', $a)) {
    echo 'true';
}
Source by www.datainfinities.com #
 
PREVIOUS NEXT
Tagged: #string #match #php
ADD COMMENT
Topic
Name
4+5 =