Remove one or more values from array in PHP

The solution is quite simple: Using built-in function array_diff of PHP: $dest_array = array_diff($src_array, array(“value_to_remove_1”, “value_remove_2”)); Of course you can use this method to remove just one value from array: $dest_array = array_diff($src_array, array(“value_to_remove”)); One problem of this method is that, there are some holes in $dest_array after apply this method. There are some ways of solving that problem: Remove all key strings from the array and replace them with numbers, use array_values Preserve the key names (strings), or reindex the array if all keys are numerical, use array_merge

Install Django on Bluehost shared hosting

In this series, I will tell you how to install several development tools on Bluehost shared hosting. Why need to purchase a VPS or dedicated hosting if your site is small, and you can install almost everything on Bluehost shared hosting. Take a look at Install git on Bluehost shared hosting to see how I managed to install git on Bluehost. Pretty easy. Bluehost support 2 versions of Python: 2.4 (default) and 2.6. Type python in command line and you will get Python 2.4. In order to run python script with Python 2.6, you have to type python2.6 instead. First, you have to specify where to install Django python package — it must be inside your home directory because everything else outside this directory (not everything actually, you can write in /tmp also, but who want to put their file into /tmp?) is read-only. My case is ~/.local/lib/python2.6/site-packages/ Download the latest tarball from Django official site (latest version at the time of writing this entry is 1.2.4) and extract it wget http://www.djangoproject.com/download/1.2.4/tarball/ tar -xzf Django-1.2.4.tar.gz cd Django-1.2.4 Install Django is pretty easy. Type the following line into command line window: python2.6 setup.py install –user Add the following line to .bashrc inside your home directory. Logout and login again after that. export PATH=$HOME/.local/bin:$HOME/.local/usr/bin:$PATH All done. You can test your Django installation by typing python at the command prompt and hit Enter. You’ll get the Python interactive interpreter, where you can type import django and hit enter. If it gives an error, then there is a problem with your installation. If no error is given, then you have successfully installed Django to your Python path. Go ahead and exit the Python shell by typing Ctrl+D.