For One of my Online Service, I wanted to provide some image results apart from my real output. So I had to search for any of the Image search API with PHP. But I didn’t get any proper solution for my requirement. Finally I’ve modified one of the Image API URL (Eg. https://www.google.com/uds/GimageSearch?rsz=8&q=sachin+tendulkar&v=1.0&start=0&imgsz=small) which I got after in depth searching. The PHP Source is really small & simple. In PHP code, I’ve used
function to read JSON response returned from the Image search API &
function (with second parameter set to true) converts the JSON string into array. You can process this final array according to your requirement.
While parsing any document (HTML, XML or aything!), You might have involved in a stage where you would need to remove numeric values (numbers) from the string. PHP has some useful function which will make this easy as butter..:)
PHP script for removing numbers from string
$myDigitsText="My 54 digi3ts contain7ed text!";
echo$myText;//This will print 'My digits contained text!'
The above PHP code makes use of the functions range(), str_replace(), trim().
range() : Create an array containing a range of elements
str_replace() : Replace all occurrences of the search string with the replacement string
trim() : Strip whitespace (or other characters) from the beginning and end of a string