Top

PHP Code Snippets by Hawkee

  (14)  
Sort by 
This is a little snippet that will remove any non-ASCII characters from a string.
Tags: ascii  pregreplace  strip 
+ 0 likes
0 comment(s)   |   Score: 0.0   |   Language: PHP   |   Posted by Hawkee on Mar 31, 2008
This code produces a sort box for any number of arbitrary criteria on any type of data you have in your database. For this particular example we've got a product sort where users can sort by price or..
Tags: database  mysql  search  sort 
+ 0 likes
1 comment(s)   |   Score: 9.0   |   Language: PHP   |   Posted by Hawkee on Mar 24, 2008
This is a very simple PHP snippet that will set $title, $meta_keywords and $meta_description for use in your page header. You'll need to create meta_tags.txt which will use this format: page_name.html|page..
Tags: dynamic  keywords  meta  php  tags  title 
+ 0 likes
5 comment(s)   |   Score: 4.0   |   Language: PHP   |   Posted by Hawkee on Dec 10, 2007
This will extract a zip file via PHP. Just be sure to set the $file and $path variables. $file represents the zip file name which may or may not contain a path. $path represents the directory to extract..
Tags: file  gunzip  unzip 
+ 0 likes
6 comment(s)   |   Score: 9.0   |   Language: PHP   |   Posted by Hawkee on Jun 21, 2007
This will assign font sizes to tags based on their counts. It tries to evenly distribute the font sizes among the tags while keeping all tags with the same counts under the same font size. The data needs..
+ 0 likes
15 comment(s)   |   Score: 8.0   |   Language: PHP   |   Posted by Hawkee on Nov 18, 2005
I thought this was pretty neat and useful. You can combine strtotime with the date function to create your own date verbally. This is just an alternative to using mktime that's a little more intuiti..
Tags: date  time  timestamp 
+ 0 likes
3 comment(s)   |   Score: 7.0   |   Language: PHP   |   Posted by Hawkee on Nov 02, 2005
This is a stand alone example of a review system. This is the administration page for entering and editing reviews. It'll create your table for you automatically, so all you need to do is change the..
Tags: editor  mysql  php  review  score 
+ 0 likes
7 comment(s)   |   Score: 10.0   |   Language: PHP   |   Posted by Hawkee on Aug 24, 2005
I've found this to be quite useful in handing uploaded files through HTTP. You can use this to move the file from your /tmp folder to a folder on your site that isn't mode 777. The concept is simple...
Tags: copy  file  ftp  http  secure 
+ 0 likes
3 comment(s)   |   Score: 7.3   |   Language: PHP   |   Posted by Hawkee on Mar 13, 2005
This will download a datafeed to your server from the given FTP account. This only supports CSV datafeeds and requires a minor tweak to accomodate any other type of datafeed. It also requires that you..
Tags: csv  datafeed  ftp  import  mysql  wget 
+ 0 likes
3 comment(s)   |   Score: 7.3   |   Language: PHP   |   Posted by Hawkee on Mar 10, 2005
This is a ready to go PHP script that can be pasted into a blank .php document. Run it through your webserver after changing $myemail to the value of your E-Mail address. It also sends the referring..
+ 0 likes
19 comment(s)   |   Score: 6.0   |   Language: PHP   |   Posted by Hawkee on Sep 04, 2004
This is very handy for making a yyyymmddhhmmss date look pretty.
Tags: convert  mktime  mysql  pubdate  rss  timestamp 
+ 0 likes
1 comment(s)   |   Score: 5.0   |   Language: PHP   |   Posted by Hawkee on Aug 29, 2004
This generates two structures: a tree and a list of objects. Both are generated from the following standard parent/child database format: - cat_id: primary key, auto_increment - cat_title: name of..
+ 0 likes
7 comment(s)   |   Score: 8.3   |   Language: PHP   |   Posted by Hawkee on Aug 20, 2004
I use this almost every day. It's one of the most useful PHP debugging tools. You can print all of the contents of a variable (class, array or scalar) to get an idea of how the structure looks.
Tags: printr 
+ 0 likes
1 comment(s)   |   Score: 3.0   |   Language: PHP   |   Posted by Hawkee on Aug 12, 2004
This will convert a sortable YYYY-MM-DD date into a more presentable date. $date can be set to any date as long as it fits this format.
Tags: convert  date  yyyymmdd 
+ 0 likes
3 comment(s)   |   Score: 5.0   |   Language: PHP   |   Posted by Hawkee on Aug 11, 2004
Bottom