Category: PHP, javascript

A blog on PHP, JavaScript and more Amit Merchant · June 13, 2020 · ⋆ PHP Who would’ve thought that PHP would have to wait till its version 8 or rather 25 years after its inception, to get a truly native and understandable function to check if a string is contained in another string?!

Prior to PHP 8 or up until now, the way that many of us used to check if the specified string is there within an another string or not was by using function strpos like so.

So, in order to fix this, this RFC attempts to add a new function called str_contains which checks if a string is contained in another string and returns a boolean value (true/false) whether or not the string was found.

So, str_contains takes a $haystack and a $needle as arguments, checks if $needle is found in $haystack and returns a boolean value (true/false) whether or not the $needle was found.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners