Strings In Depth15 / 18
Up next

Find a position

<?php
declare(strict_types=1);
$s = "user@example.com";
// strpos returns the index of the first match
echo strpos($s, "@"), "\n";
// test with === false, since 0 is a valid index
var_dump(strpos($s, "z") === false);
What you're solving

strpos returns an index or false