I am using the following code on my site to display a thumbnail produced by the TimThumb script:
<img src="timthumb.php?src=<?php echo $image_url[0]; ?>&h=100&w=150" />
It works fine except when the image URL contains ‘+’. I think it is seeing the ‘+’ as a space. Is there a simple way to replace the ‘+’ symbol with ‘%2B’? I’m not a coder sorry but I guess it would be something like ‘str_replace’?
As Ignacio said, you can use urlencode, however, it’s often easier to let http_build_query handle it for you:
In this situation, urlencode is a lot shorter and cleaner looking, however, I’ve found that http_build_query tends to generalize better (especially when the number of parameters is not fixed).