Posts

Avoid Image width and height distraction with CSS.

Hi! Hope everyone is fine! Today i am going to share how to avoid image distraction with CSS.Have a look below code and it will do magic! Here is your HTML code, <a href="#" class="img-thumbnail"> <img src="image1.jpg"  /> </a> Here is you CSS code, .img-thumbnail{     background: none repeat scroll 0 0 #111111;     display: inline-block;     height: 160px;     overflow: hidden;     width: 200px; } .img-thumbnail img {     width: 100%; }

How to add comma (,) and AND (&) atlast using implode

Hi, I see many of them will be thinking how to display array values with comma but to display last one as &. Here is the code where it will list all the array values with comma separated but last value it will replace &. $arr = array('red','pink','blue','violet'); $last = array_pop($arr); $string = count($arr) ? implode(", ", $arr) . "& " . $last : $last; Output:  ------------ red, pink, blue &violet Hope this will be useful.

Redirect 404 page through .htaccess

Hi, Today i am going to explain how to redirect 404 page using .htaccess. Here is the code, you have to put this code in your .htaccess file which will be under root directory. <IfModule mod_rewrite.c>   Options +FollowSymlinks   RewriteEngine On   RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$  /404.php </IfModule>   Its very easy to use. If your .htaccess is not working you have to enable it from apache.  Please follow these steps, 1. Open your httpd.conf file 2. Make sure LoadModule rewrite_module modules/mod_rewrite .so line should be enable (by removing # before this line.)

Get Android version using Javascript

Hi! Today i am going to share how to get android version using Javascript. Here is the code, <script> function getAndroidVersion(ua) {     var ua = ua || navigator.userAgent;     var match = ua.match(/Android\s([0-9\.]*)/);     return match ? match[1] : false; }; getAndroidVersion(); //"4.2.1" parseInt(getAndroidVersion(),10); //4 parseFloat(getAndroidVersion()); //4.2 </script> Hope you got it. Any queries please leave a comment.

Expedia PHP SimpleXML API code

Hi, Today i am going to share how to retrieve datas from XML using expedia API sandbox. Here you find Expedia API Tester, http://devhub.ean.com/apitester/index.html You can use any queries based on your requirement. Then you have to process the query. Once done, you will get API link using this link you can retrieve Array in PHP. Here you go, <?php $context  = stream_context_create(array('http' => array('header' => 'Accept: application/xml'))); $api_key = '***********'; $url = 'http://api.eancdn.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=150&apiKey='.$api_key.'&locale=en_US&currencyCode=USD&xml=<HotelListRequest><city>Seattle</city><stateProvinceCode>WA</stateProvinceCode><countryCode>US</countryCode><arrivalDate>2/16/2014</arrivalDate><departureDate>2/18/2014</departureDate><RoomGroup><Room><numberOfAdults>2</nu...

Geo Location - Get location based on where you are

Hi, Today i am going to share script how to get location based on where you are located.  Here is the script, <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>GMap location</title> <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"> </script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script> $(document).ready(function() {  navigator.geolocation.getCurrentPosition(function (pos) {     var geocoder = new google.maps.Geocoder();     var lat = pos.coords.latitude;     var lng = pos.coords.longitude;     var latlng = new google.maps.LatLng(lat, lng);      //reverse geocode the coordinates, returning location information.     geocoder.geocode({ 'latLng': latlng }, function (results, st...

Javascript function to display 2 digit number

Hi, Today i am going to share how to display 2 digit number in javascript and jQuery, Javascript: ------------- function twodigit(num) {          var num1 = parseInt(num, 10);           return num1 < 10 ? "0" + num1 : num1;     } JQuery: --------- $('#count').text(function(i,num) {   var num1 = parseInt(num, 10);   return num1 < 10 ? "0" + num1 : num1; }); Output: ---------- twodigit(1); // returns 01 twodigit(2); // returns 02