Posts

Showing posts from January, 2014

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...