From Break the Network: –
Getting started with string manipulation in php:
When working with php, you will often come across the common problem of replacing or grabbing a specific chunk of a string. The way I look at it, you have two main options that come directly out of php’s function api. You can either use a simple, quick and easy str_replace() function, or you can dive into the world of regular expressions and tackle the problem a little more smartly using preg_replace().