Welcome To Snipplr


Everyone's Recent Snippets Tagged array



without scandir() function
0 936 posted 15 years ago by stancox
This is inspired by this http://www.cgi101.com/book/ch5/text.html so I'm using a similar example. In PHP you can combine a set of checkboxes into an array using square brackets like this: <form> <input> Red<br> <input> Green<br>...
1 1357 posted 15 years ago by ptepper
Shortens all strings in an array to a maximum length. Inserts '...' in between the first and last 6 letters
0 1337 posted 15 years ago by svenito
Given a start path will return an array of all subdirectories excluding files
0 1275 posted 15 years ago by svenito
Remove $value from $array
0 848 posted 15 years ago by svenito
Ensures all elements in an array are unique newArray = myArray.unique();
0 820 posted 15 years ago by svenito
This extends arrays withe a removeItems operation to remove all occurances of <item> from <array> usage: myArray.removeItems("words");
0 857 posted 15 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 721 posted 15 years ago by evilwalrus
This function returns the array with all instances of the specified value removed
1 1164 posted 15 years ago by jlvallelonga
Perl hash sets are hashes used to represent sets. Their keys are the set elements, and the corresponding values are just 1. For keys that are not set elements, the hash will return undef, equivalent to false. Adding a whole array to a hash set i...
0 1196 posted 15 years ago by deepsoul
Checks if an array has been initialized, even if it is a dynamic array.
1 1105 posted 15 years ago by wizard04
0 886 posted 15 years ago by iloveitaly
Detect if an object exists in an array or detect existance of a key in an object
1 938 posted 15 years ago by quickredfox
Convert a coordinate (x,y) into the index for a 1D array. For example, the coordinate (3,1) would be at array index 8 if there are 5 columns. Assumption: Arrays start at 0.
0 1403 posted 15 years ago by helloworlder
0 867 posted 15 years ago by jpsirois
Convenience function to set a SimpleXMLElement's attributes quickly.
0 939 posted 15 years ago by iloveitaly
0 716 posted 15 years ago by iloveitaly
Need a function to clean your _POST array before inserting into a database? Just pass $_POST to this function.
1 1379 posted 15 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 831 posted 15 years ago by the_dev
Like python's os.listdir
1 1257 posted 15 years ago by iloveitaly
0 652 posted 15 years ago by iloveitaly
1 1313 posted 15 years ago by traeregan
3 1151 posted 16 years ago by cshaiku
2 1166 posted 16 years ago by cshaiku
Adds a method to the Array object that lets you slice the array down to everything before the given value.
0 732 posted 16 years ago by segdeha
like array_key_exists but accepts an array of key values to check
0 746 posted 16 years ago by iloveitaly
2 1226 posted 16 years ago by iloveitaly