Welcome To Snipplr


Everyone's Recent PHP Snippets



1 ... 106 107 108 109 110 ... 147
this comes from YAPB plugin for WordPress. kudos to the author. (there are some functions that are deprecated in PHP 5.2+ - you'll need to replace eregi with the mb_ version). This should be quite failsafe, regardless if curl is installed or the set...
1 1448 posted 15 years ago by iroybot
Sometime it is convenient to get recursive directory listing as array of items directory => (file array) Such as: Array ( [./a2temple] => Array ( [0] => example13.zip )...
2 1016 posted 15 years ago by artoodetoo
If you want to set the active menu trail in a node, simply add this to your template.php in the 'template preprocess node' function.
0 900 posted 15 years ago by ccalnan
To make an image browser, add these lines: $ext = strtolower(substr("$dirArray[$index]", strrpos("$dirArray[$index]", '.') + 1)); //get file extensions if ("$ext" == "jpg") { // if file is a jpg print("<TR><TD>$dirArray[$index]<br/><a href=\...
1 1124 posted 15 years ago by beneberle
Shortens all strings in an array to a maximum length. Inserts '...' in between the first and last 6 letters
0 1508 posted 15 years ago by svenito
Given a start path will return an array of all subdirectories excluding files
0 1393 posted 15 years ago by svenito
Remove $value from $array
0 943 posted 15 years ago by svenito
0 873 posted 15 years ago by zemin
Allows you to convert to any base between 2 and 255, effectively using all the ASCII characters. In order to convert very large numbers with arbitrary precision you’ll need the BCMath lib. Without BCMath the large numbers will not be converted c...
1 1205 posted 15 years ago by bucabay
to
0 924 posted 15 years ago by mware1205
This snippet allows you to update multiple rows of a database using a single form in one easy click
0 1791 posted 15 years ago by daveismyname
This snippet collects a date from a var and formats it into the correct format for database date entry
0 1244 posted 15 years ago by daveismyname
There are plenty of classes out there to paginate through database results, well, here's one to paginate through a static array of items. Written quite a few years ago, recently recovered from a crashed drive.
1 766 posted 15 years ago by evilwalrus
2 login functions that check if a user is logged in by checking is a session is equal to true that would have been set on login. If not logged in the redirect to login.php
1 1093 posted 15 years ago by daveismyname
very useful function that allows you to redirect to the user to a given location
1 1255 posted 15 years ago by daveismyname
Sometimes, the first or last block in a region needs to be styled different than the rest. This solution do this in simple way for Drupal 6. (originaly code from [email protected]: http://drupal.org/node/293188#comment-1282186)
2 1171 posted 15 years ago by Fake
Some valid UTF-8 characters are illegal in XML: http://www.w3.org/TR/REC-xml/#charsets This statement strips them from your strings.
0 2915 posted 15 years ago by jdbartlett
1 1410 posted 15 years ago by AzizLight
A simple function that generates a select drop down. It takes 3 values. The select name ,the mode (true for hours / false for minutes) and the selected option.
1 1454 posted 15 years ago by chchrist
Search Engine Optimisation, or SEO is something that a lot of bloggers get obsessed about, whilst others think it’s a load of rubbish. I’m halfway between the two – whilst I believe that you can change certain things to better SEO your content,...
0 961 posted 15 years ago by paulgrenwood
Whilst there are a number of ways of displaying thumbnails, this is still my favourite (even if it does require the most work!). First, upload timthumb to /wp-content/themes/yourtheme/ and create an image 250px by 250px with your site’s logo and up...
0 1128 posted 15 years ago by paulgrenwood
This is something that I wished I’d thought of a long time ago – show other posts in the same series using not a plugin but custom fields. All you’ve got to do for this trick to work is create a custom field ‘Series’ with a link to each oth...
1 997 posted 15 years ago by paulgrenwood
Allow Visitors to Email Posts to Their Friends
0 950 posted 15 years ago by paulgrenwood
1 976 posted 15 years ago by paulgrenwood
2 1141 posted 15 years ago by paulgrenwood
E-mail validation is perhaps the most used validation in web forms, this code will validate email address and also optionally check the MX records of the domain provided in email address to make email validation more robust.
2 1318 posted 15 years ago by paulgrenwood
This function will truncate strings only at word breaks which can be used to show a teaser for complete article without breaking words.
0 1190 posted 15 years ago by paulgrenwood
1 ... 106 107 108 109 110 ... 147