Category: Programming

PHP usort explained

The usort function sorts an array by values where the values are sorted by a user-defined function. usort has the following syntax The comparison function takes two arguments and it…

is_dir not working

The is_dir() function in PHP allows users to check whether a file is a directory. It returns true if the file is a directory. However, the addresses provided must be…

PHP: Encrypting and Decrypting

The crypt() function provide one-way encryption. Using one-way encryption is like using a key to lock and unlock something. The key is your password. To encrypt: To decrypt:

PHP: File functions

Opening directory and listing files See the following code: output: To remove certain file name from the list, see the following code: This code lists all files except the ones…

PHP: How to read command-line input

In PHP, all commandline parameter are passed to the $argv array. Following example shows how to use this array: $argv and $argv contain the passed parameters in the order they…

Java: removing enclosing quotes

The following code would remove enclosing quotes from Java Strings With this regular expression, if Java sees an opening double quote (^\”) or | a closing double quote (\”$) then…

Java Stack

Stack is a LIFO ADT (Last in first out abstract data type) and a linear data structure. In a jar the items on top (i.e. items that went in last)…