Category: php
-
Linux – Install Eclipse IDE
The easiest way to install Eclipse in Ubuntu is through the standard repository sudo apt-get install -y eclipse Unfortunately, this install an outdated version. Currently the version 3.8.0 gets installed, although the latest stable version is 4.2.1. The eclipse team does have a Debian PPA as well, ppa:eclipse-team/debian-package. Adding this PPA doesn’t change anything and…
-
PHP – Reliable Array Size
Code: function size($array) { if (isset($array) && is_array($array)) { return sizeof($array); } return 0; }
-
PHP – make an array unique – remove duplicates
Code: /** * Removes duplicate keys from an array * * @param array $array * @return array */ function array_unique_key($array) { $result = array(); foreach (array_unique(array_keys($array)) as $tvalue) { $result[$tvalue] = $array[$tvalue]; } return $result; }
-
PHP – Simple Function for URL Redirection
Redirecting to another URL in PHP requires passing the Location header and exiting thereafter: Though this method does work, I find it rather unclean. So, I prefer specifying the HTTP status code and also returning HTML/JavaScript for redirection. The HTML can be quite using when the page client is on a connection with very limited…