Delete particular word from string

Viewed 107453

I'm extracting twitter user's profile image through JSON. For this my code is:

$x->profile_image_url

that returns the url of the profile image. The format of the url may be "..xyz_normal.jpg" or "..xyz_normal.png" or "..xyz_normal.jpeg" or "..xyz_normal.gif" etc.

Now I want to delete the "_normal" part from every url that I receive. How can I achieve this in php? I'm tired of trying it. Please help.

6 Answers

The str_ireplace() function does the same job but ignoring the case

like the following

<?php
echo str_ireplace("World","Peter","Hello world!");
?>

output : Hello Peter!

for more example you can see

Multi replace

$a = array('one','two','three');
$var = "one_1 two_2 three_3";
str_replace($a, '',$var);
Related