Skip to main content


Showing posts from 2006


One of the first kinds of programs learned by a student is how to determine if a string is a palindrome. A palindroms is a word or string that is spelled the same backwords as it is forwards. An example would be "rotor".<?php$test="rotor"; if ($test==strrev($test)) { echo"This is a palindrome"; } else { echo"This is NOT a palindrome"; } ?>

Export HTML to Excel

Export to Excel Today I learned a cool trick of how to export data that I have arranged in tables to an excel file quick and easy. Below is a sample of some code. To make it work copy the following code into its own php file. You will notice that in the code there are to function calls to the header. The first is the Content-Type which gives the browser the information needed to use excel to open the document. The second is the Content-disposition. This allows the user the option to save the document as an excel file, with a default or custom filename.<?php header("Content-Type: application/; name='excel'"); header("Content-disposition: attachment; filename=test.xls"); ?><tableborder="1"><tr><td>test</td><td>=3+4</td></tr><tr><td>test</td><td>test2</td></tr><tr><td>test</td><td>test2</td></tr></table>