top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to check if string contains specific words using PHP?

0 votes
297 views
How to check if string contains specific words using PHP?
posted Jul 12, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

Use strpos to check as it returns true when first position of substring occurs in given main string.

$yourmainString = 'You are at tech.queryhome.com';
if (strpos($yourmainString, 'tech.queryhome.com') !== false) {
    echo 'Thanks';
}
answer Jul 12, 2016 by Shivam Kumar Pandey
Similar Questions
0 votes

Here i want to know any simple way to check whether NSMutableArray contains specified object. I used for loop to find the object at index is same or not, but its get sucks processing because my array contains plenty of objects.

+1 vote

I am tring to create a new table into the database if the table name given is not present in database using Php .
This is the code that I am using .

  $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(!$conn)
    {
            die('Failed to connect to server: ' . mysql_error());
            exit;
    }
    $db_selected = mysql_select_db($dbname);
    if(!$db_selected)
    {
           $db_selected = " CREATE DATABASE $dbname ";
    }
    $usertb1 = mysql_query("select 1 from $usertb LIMIT 1");
    if( $usertb1 !== FALSE )
    {
           $sql = "CREATE TABLE IF NOT EXISTS $usertb ( uid INT(20) AUTO_INCREMENT UNIQUE KEY NOT NULL,name VARCHAR(40),email varchar(40) PRIMARY KEY NOT NULL)";
    }
    $typetb1 = mysql_query("select 1 from $typetb LIMIT 1");
    if( $typetb1 !== FALSE)
    {
           $sql1 = "CREATE TABLE IF NOT EXISTS $typetb( uid INT(20) NOT NULL, type ENUM('WEB','APP','CART') NOT NULL ,unsubscribe TINYINT(1) NOT NULL,bounce TINYINT(1) NOT NULL,complaint TINYINT(1) NOT NULL, PRIMARY KEY (uid,type), FOREIGN KEY(uid) WHERE promo_user(uid))";
    }
...