Dave Tips

Tips for computers and the internet. How to, tips, tricks and resources for computers and the web.

Tuesday, September 25, 2007

Comma Separated Value (CSV) Files with PHP

Comma Separated Values File Format can be used within a PHP. This can be useful to manipulate data that already exists in .csv files, or to easily create a datafile with either a program (like Excel) or by hand. Here are some more resources about PHP and the CSV File Format:

Labels: , ,

Sunday, September 2, 2007

Unix Timestamp Converter

An online tool to covert a date and time into a Unix Timestamp (time measured in the number of seconds since the Unix Epoch [January 1 1970 00:00:00 GMT]).

Labels:

Wednesday, March 28, 2007

AB split test in PHP

If you have a web site, and you run ads on it, you probably want to make the most money you can. This means testing out different sizes, layouts, colors, and even types of ad to see which ones make the most money. One of the easiest ways to find the most profitable ad, is to run a split test.

An AB split test runs one ad, the "A" ad, part of the time, and shows a second, the "B" ad, the other part of the time. After they've each been displayed many times, the results of the two different ads can be compared. Then, replace the less profitable ad with a new format/color/etc. and run the test again. This way you'll refine the ads over time, and always be lookng to improve your revenue.

If you host your site somewhere that supports PHP, you can set up an AB split test using this code:

<?php
if (rand(1, 100) > 50) { // display this 50% of the time
echo "A ad's code is here";
}
else { // display this the other 50% of the time
echo "B ad's code is here";
}
?>


You can change the code to display each ad whatever percentage of the time you choose. Just change the last number in this line:

if (rand(1, 100) > 50)

For example, using the number 80 (instead of 50) displays ad A %20 of the time, and the other 80% of the time, the B ad is displayed.

Note: If your ad code has a quote characters in it, you must escape them by putting a backslash \ before the quote character so php will not see them as the end of the echo string.

Labels: ,

Friday, March 2, 2007

PHP Function Reference

The Invauluable resource for writing PHP web sites, it deals with all the syntax and other good stuff.

Labels: ,