Working with strings

Working with strings in real life is really easy. Actions like Check if this string contains this or Tell me how many times this character appears are very easy to perform. But when programming, strings are concatenations of characters that you cannot see at once when searching for something. Instead, you have to look one by one and keep track of what the content is. In this scenario, those really easy actions are not that easy any more.

Luckily for you, PHP brings a whole set of predefined functions that help you in interacting with strings. You can find the entire list of functions at http://php.net/manual/en/ref.strings.php, but we will only cover the ones that are used the most. Let's look at some examples:

<?php $text = ...

Get Learning PHP 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.