Return to Snippet

Revision: 58504
at July 18, 2012 23:32 by satie83


Updated Code
$intPos = strpos($strHaystack,$strNeedle);

if( $intPos === false ) {
     // string strNeedle NOT found in strHaystack
} else {
     // string strNeedle found in strHaystack
}

Revision: 58503
at July 18, 2012 20:48 by satie83


Initial Code
$intPos = strpos($strHaystack,$strNeedle);

if( $pos === false ) {
     // string strNeedle NOT found in strHaystack
} else {
     // string strNeedle found in strHaystack
}

Initial URL
http://www.maxi-pedia.com/string+contains+substring+PHP

Initial Description
Once in a while we need to check whether a string contains substring, some other string or characters or a value. Checking for existence of a string (or substring) inside another string is easier than it might seem. The following article describes how to check for whether a string contains string in PHP, or simply said how to find string within string in PHP.

Initial Title
PHP - How to check if string contains substring PHP

Initial Tags
php

Initial Language
PHP