How do I check if my string starts with a certain word in PHP? [closed]

As an alternative to substr() you could also use strpos()

$str="Personal-imiY2cdnpL01EzbZWr2YWzukkJmC3K6BMQpZU2wgfsOehCruDr";
if (strpos($str, 'Personal') === 0) {
    // do stuff
}

Leave a Comment