Removing last comma in a string – PHP

Hi guys, Here I am gonna share how to remove the last comma in a string by using php rtrim function. The rtrim() function will remove whitespaces or other predefined character from the right side of a string. Syntax rtrim(string,charlist) Example : $text_with_comma = “1,2,3,4,5,6,7,”; $removed = rtrim($text_with_comma, ‘,’); Output … Read more

How to find the text in string using PHP

Hi guys here I am going to share how to find a text inside a particular given string by using PHP here is the code $string_t0_search = “PHP”; $paragraph = “I love writing PHP code.”; if(strstr($paragraph,$string_to_search)) { echo “found it.”; } else { echo “not found.”; } strstr() is php … Read more

New features in PHP 5.4 version

The process to release PHP 5.4 is moving on. As you probably know, the updates that were intended for postponed PHP 6 were added to PHP 5.4.0 instead, so now PHP includes a huge set of new language features and removes several legacy behaviors. Because of that I created a list of … Read more

How to calculate distances in PHP

Here is a very handy function, which calculate the distance from a point A to a point B, using latitudes and longitudes. The function can return the distance in miles, kilometers, or nautical miles. [php][file]http://w3lessons.info/wp-content/uploads/2011/12/calculate_distance1.txt[/file][/php] Usage Using the function is pretty simple: All you need to do is to call … Read more

How to execute cron job in codeigniter using PHP

Introduction to Cron jobs in Codeigniter Codeigniter runs based on the front controller pattern where all the requests are routed using the index.php file. So if we want to execute any code on codeigniter application, we have to go through this routing procedure. Consider a situation where we want to … Read more

Generate Dynamic Favicon in PHP

Gmail has just launched small but really useful feature in Gmail Labs. Dynamic Favicon showing unread email counts directly in your browser tab icon. If your browser window has lots and lots of tabs open at anytime, this might be really a wonderful feature that lets user know of any unread item. … Read more

Built-in Web Server Environment in PHP 5.4

Well, here is some really good news for the PHP Development community. Till now (as of PHP 5.3) all developers had to set up a web-server environment such as Apache in order to test all their PHP codes. Not only this, apart from installing the server environment developers also have … Read more

PHP and htaccess tips and tricks

17 useful htaccess tips and tricks – http://www.queness.com/post/5421/17-useful-htaccess-tricks-and-tips How to get all social media members count by using php Feedburner Twitter Facebook Delicious It grab the total number of twitter followers, feedburner subscribers and also delicious bookmarks of your account/website. 1 2 3 4 5 6 7 8 9 10 11 … Read more

Get domain favicon using PHP and Google

These days, many websites or webapps are using favicons from other websites. Displaying a favicon on your own site is pretty easy using Google and some PHP. function get_favicon($url){ $url = str_replace(“http://”,”,$url); return “http://www.google.com/s2/favicons?domain=”.$url; }