Created
December 16, 2018 15:01
-
-
Save MohamedLamineAllal/0924ccdc0cb16003d870c1cbe344598c to your computer and use it in GitHub Desktop.
PHP boiler plate (Important things that we use often)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// indexOf equivalent (get pos of a string within another) | |
int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) | |
// http://php.net/manual/en/function.strpos.php | |
$pos = strpos($mystring, $findme); | |
// Note our use of ===. Simply == would not work as expected | |
// because the position of 'a' was the 0th (first) character. | |
if ($pos === false) { | |
echo "The string '$findme' was not found in the string '$mystring'"; | |
} else { | |
echo "The string '$findme' was found in the string '$mystring'"; | |
echo " and exists at position $pos"; | |
} | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment