php - How to remove variable in img src tag? -


i have sample code:

$filename = 'http://thebox.vn/uploaded/catmy/2013_04_23/couple_t2.jpg?maxwidth=480'; 

and using code remove variable (maxwidth)

echo preg_replace('/(\?)$/', '', $filename) 

=> how remove variable (maxwidth), how fix ?

you may try this

$filename = 'http://thebox.vn/uploaded/catmy/2013_04_23/couple_t2.jpg?maxwidth=480'; echo preg_replace("/\?[a-z]+=\d+/", '', $filename); 

demo.


Comments