Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete particular word from string

Tags:

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.

like image 391
user188995 Avatar asked Aug 18 '12 09:08

user188995


1 Answers

Php str_replace.

str_replace('_normal', '', $var) 

What this does is to replace '_normal' with '' (nothing) in the variable $var. Or take a look at preg_replace if you need the power of regular expressions.

like image 161
Matsemann Avatar answered Nov 10 '22 18:11

Matsemann