|
|
|
|
|
|
|
|
|
Like this code?
Show the author your appreciation.
|
| |
| <?php
function Google_Calculator($query)
{
$matches = array();
if (preg_match('~<b>.+? = (.+?)</b></h2>~', file_get_contents('http://www.google.com/search?q=' . urlencode($query)), $matches) > 0)
{
if (array_key_exists(1, $matches) === true)
{
return $matches[1];
}
}
return false;
}
?> | |
Usage:
| <?php
Google_Calculator('2 + 2'); // 4
Google_Calculator('5 + 5 * 10'); // 55
Google_Calculator('(5 + 5) * 10'); // 100
Google_Calculator('1 USD to EUR'); // 0.768816791 Euros
Google_Calculator('1 EUR to USD'); // 1.3007 U.S. dollars
Google_Calculator('the answer to life, the universe and everything'); // 42
?> | | |
|
| PHP Script to find url links in a page Categories : PHP, URLs, Regexps, Arrays | | | BBCode Formatting String Categories : PHP, HTML, Regexps, Arrays | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays | | | Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other? Categories : PHP, Math., Arrays | | | Stock quotes from yahoo! Categories : PHP, Web Services, Arrays | | | Get the AppStore Ranking for any iPhone App Categories : PHP, Web Services, Regexps | | | columned txt file to array()? Categories : Arrays, Strings, Regexps, PHP | | | Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects. Categories : PHP, PHP Classes, XML, Web Services | | | String Replacement and speed consideration
Categories : PHP, Strings, Regexps | | | Validating a URL with preg_match Categories : PHP, Regexps, Beginner Guides, Data Validation | | | PHP Youtube Downloader - This is a set of PHP functions that can be used to download movies from Youtube.com.
Categories : PHP, CURL, Regexps | | | enhanced date picker with jcript checking for a dynamic date input Categories : PHP, Java Script, Date Time, Calendar, Arrays | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | | | making links from text Categories : PHP, Regexps, Email | |
| |
| |
|