Contact: aviboots(AT)netvision.net.il
31,166 questions
40,722 answers
573 users
$string = 'XAMPP Control Panel'; $find = 'Control'; $pos = strpos($string, $find); echo $pos; /* run: 6 */
$string = 'XAMPP Control Panel'; $find = 'Control Power'; $pos = strpos($string, $find); if ($pos !== false) echo $pos; else echo "string not found"; /* run: string not found */
$string = 'XAMPP Control Panel'; $find = 'C'; $pos = strpos($string, $find); if ($pos === false) echo "string not found"; else echo $pos; /* run: 6 */
$string = 'XAMPP Control Panel'; $find = 'A'; $pos = strpos($string, $find, 3); // srart search from char 3 if ($pos === false) echo "string not found"; else echo $pos; /* run: string not found */
$string = 'XAMPP Control Panel Apache + MySQL + PHP + Perl'; $find = 'A'; $pos = strpos($string, $find, 3); // srart search from char 3 if ($pos === false) echo "string not found"; else echo $pos; /* run: 20 */
$string = '1234567'; $find = 1; // 1 without apostrophes '' $pos = strpos($string, $find); if ($pos === false) echo "string not found"; else echo $pos; /* run: string not found */
$string = '1234567'; $find = '1'; $pos = strpos($string, $find); if ($pos === false) echo "string not found"; else echo $pos; /* run: 0 */