Welcome To Snipplr


Everyone's Recent PHP Snippets Tagged array



Shortens all strings in an array to a maximum length. Inserts '...' in between the first and last 6 letters
0 2139 posted 16 years ago by svenito
Given a start path will return an array of all subdirectories excluding files
0 1882 posted 16 years ago by svenito
Remove $value from $array
0 1349 posted 16 years ago by svenito
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 1102 posted 16 years ago by evilwalrus
0 1295 posted 16 years ago by iloveitaly
0 1396 posted 16 years ago by jpsirois
Convenience function to set a SimpleXMLElement's attributes quickly.
0 1377 posted 16 years ago by iloveitaly
0 1050 posted 16 years ago by iloveitaly
Need a function to clean your _POST array before inserting into a database? Just pass $_POST to this function.
1 2930 posted 16 years ago by the_dev
It's easy to print out an array that is readable and with only one line of code. This can easily be turned into a nifty function.
1 1364 posted 16 years ago by the_dev
Like python's os.listdir
1 1938 posted 16 years ago by iloveitaly
0 1007 posted 16 years ago by iloveitaly
3 2079 posted 16 years ago by cshaiku
2 2010 posted 16 years ago by cshaiku
like array_key_exists but accepts an array of key values to check
0 1171 posted 16 years ago by iloveitaly
2 2145 posted 16 years ago by iloveitaly
1 1512 posted 17 years ago by michaelfox
1 1648 posted 17 years ago by apro2000
Instead of one element you can insert multiple at once: array($element1, $element2, $element3)
1 2015 posted 17 years ago by kurokikaze
Usage: define('PIRATE',bindec('0001')); // 1 define('NINJA',bindec('0010')); // 2 define('JEDI',bindec('0100')); // 4 define('ADMIN',bindec('1000')); // 8 $rpermit = array(PIRATE,JEDI); // Equivilent Flags '0101'...
0 1167 posted 17 years ago by Jdub7
1 1993 posted 17 years ago by jamierumbelow
0 1601 posted 17 years ago by giroro
I don't wanna forget this small yet useful line.
1 1700 posted 17 years ago by axthos
very easy to use pagination class, see website for comments
1 2671 posted 17 years ago by localhorst
Pre-selects an html form with a requested value... ie; editing a form from a database
0 1684 posted 17 years ago by davidsword