Category Archives: PHP

PHP, which stands for Hypertext Preprocessor, is a widely-used open-source server-side scripting language primarily designed for web development. It was created by Danish-Canadian programmer Rasmus Lerdorf in 1994 and has since become one of the most popular programming languages for web development.

PHP how to sort array with user defined keys

Many times, we need to do sort array with some user defined keys. So we can use pre defined php function to make it easier.  We can array_flip function to achieve it, array_flip — Exchanges all keys with their associated values in an array.  array_flip() returns an array in flip order, i.e. keys from array become values and values from array become keys. Note… Read More »

How to redirect non www or non https url to www and https

This is very common problem to everyone to redirect non www urls to www with https. You can follow simple .htaccess rules to implement it. RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] The only real difference here is that first we redirect from non-WWW to… Read More »