Archive for January, 2008
Get the Current Directory
Sometimes you write a function in PHP that needs to know where in the directory hierarchy the code is being called from, to correctly access other files, such as those to be read, written or included. If the same function appears throughout your site, you can’t ‘hard code’ the location, because it changes from one [...]
Filed under: Functions | Leave a Comment
Make a Choice with SWITCH()
The switch() function lets you choose between several options, depending on the value some variable takes. It is similar, for those of you who have programmed in Visual Basic, to the select case command in that language.
So, let’s say you have a feedback form with a drop-down list of typical reasons someone might have for [...]
Filed under: Functions | Leave a Comment
Remove Duplicates from an Array
Sometimes you have an array of elements that may contain duplicate entries, but you do want any duplication. Randomly selected elements are a good example of this. If you add elements to an array one at a time using the random function, it can return the same value more than once.
Removing any duplicates is easy [...]
Filed under: Functions | Leave a Comment
String Position strpos()
Sometimes when coding a PHP script, you find you need to manipulate strings of text or data. Part of that process may require that you find a particular part of a string, containing known characters. The strpos function lets you find the location of one string within another.
The basic format is:
$pos=strpos($mystring,$searchstring,$start);
First, remember that PHP begins [...]
Filed under: Functions | Leave a Comment
Easy Niche Store Review
If you want an easy way to make money with PHP, even before you learn all of the ins and outs of programming scripts of your own, there are some handy resources available to help make your website profitable. Easy Niche Store is one of those.
This Easy Niche Store review will explain how it works. [...]
Filed under: Resources | Leave a Comment
Search
-
You are currently browsing the PHP Basics weblog archives for the month January, 2008.