I faced again with problem of posting PHP code on blogger. So here is very simple and nice Code converter for posting code on Blogger.
http://francois.schnell.free.fr/tools/BloggerPaste/BloggerPaste.html
Wednesday, August 24, 2011
Simple Google Weather Unofficial Api
Hey guys. If you are searching for very simple google weather Unofficial api, so here is the code for it.
<?php //Created by Roman Losev 2011 //http://pilotaz.blogspot.com/ //email: pilotaz@gmail.com //Thanks for feedback. $url = "http://www.google.com/ig/api?weather=Vilnius+Lithuania&hl=lt"; ini_set("user_agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0"); ini_set("content_type","text/xml; charset=\"UTF-8\""); ini_set("accept_charset","utf-8;q=0.7,*;q=0.7"); ini_set("max_execution_time", 0); ini_set("memory_limit", "1000M"); $xml = simplexml_load_file($url); $image_size = "80"; $count = 0; echo '<div id="weather" align="center">'; $img = IMG_URL."me/hero_bg.gif"; echo "<table border='0' width='400' style=\"background: url(".$img.") bottom left repeat-x #FFF; border: 1px solid #EEE; padding: 20px\">"; foreach($xml->weather as $item) { echo "<tr><td colspan=\"4\" align='center'>Vilniuje šiandien: ".$item->current_conditions->temp_c['data']."° C, ".$item->current_conditions->humidity['data'].", ".$item->current_conditions->wind_condition['data']."</td></tr><tr>"; foreach($item->forecast_conditions as $new) { echo '<td style="padding: 4px;" align="center"><div class="weatherIcon">'; echo '<img src="http://www.google.com/' . $new->icon['data'] . '"/ width="'.$image_size.'" height="'.$image_size.'" style="border: 1px solid #a1a1a1"><br/>'; echo $new->day_of_week['data'].": ".$new->low['data']." - ".$new->high['data']."° C"; echo '</div>'; echo "</td>"; } } echo "</tr></table>"; echo '</div><br>'; ?>
[Solution] user agent stylesheet override site stylesheet on Chrome but not Firefox
My problem was this: i wanted to put bold on text which was in select's option by putting style - wont-weight. I had succeed only on Firefox. Because chrome user agent stylesheet were overriding my stylesheet.
I tried to solve the problem for hours. Finally with my friend's help i found the website - electrictoolbox. And it says that only firefox allows to do that... that means we cant use wont-weight on chrome for option, select and optgroup.
My solution was for the bold text changing wont-weight style into color, with dark color for normal text and lighter color for bold required. Also i needed disabling option of bold, so i just added " disabled='disabled' ". That is all..
My result:
Good luck.
Thursday, August 4, 2011
PHP string replace all except numbers and chars
Here is PHP function(code) to remove all but not characters and numbers.
http://pilotaz.blogspot.com/2011/05/php-remove-all-characters-and-leave_29.html
$result= preg_replace("/[^a-zA-Z0-9]+/", "", $text);p.s. If you are looking to delete everything but numbers, than look here:
http://pilotaz.blogspot.com/2011/05/php-remove-all-characters-and-leave_29.html
Monday, August 1, 2011
PHP multidimensional array check
Today i faced with problem that array had array inside it. It means that the array is multidimensional. So i was forced to recheck the array check with function is_array to new check. Here is the code of check:
function is_multi($a) { $rv = array_filter($a,'is_array'); if(count($rv)>0) return true; return false; }
Source: http://stackoverflow.com/questions/145337/checking-if-array-is-multidimensional-or-not
Big thanks to Vinko Vrsalovic
Subscribe to:
Posts (Atom)