Welcome To Snipplr
Everyone's Recent Snippets Tagged array
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This table is based on the ISO 2 letter (Alpha-2 code, ISO 639-1) and 3 letter (Alpha-3 code, ISO 639-2) Standard Codes for the Representation of Names of Languages.
0
2754
posted 13 years ago by rwt
Checks if two given arrays equal each other as php doesn't have a built in function for this.
0
2682
posted 13 years ago by MaxHudson
Outputs the content of a multi-dimensional array in the $GLOBALS['lv']
0
2022
posted 13 years ago by steho
Function to convert a one dimensional array to two dimensional with option to specify how many columns. Returns two dimensional array on success or false on fail.
0
3638
posted 13 years ago by kosinix
Sum all elements of a bidimensional or multi-dimensional array with an assigned key
0
2096
posted 13 years ago by eortiz
I use this primarily for debugging purposes. This simply takes an array and creates an expandable item that prints the array out in a \<pre\> wrapping, making it easy to read. Very basic snippet.
0
3032
posted 13 years ago by ringo380
The closest to a generic List in javascript.
When calling constructor - new List(Module) - add model in constructor parameter
0
1759
posted 14 years ago by mikkeldamm
The following shoud do it. pass the array, index is what element you want to sort on (in your case use 3). Then you can sort asc or desc, and weather you want to use natural sorting (the way a human would sort, 2 before 10) and lastly case sensitive...
0
1722
posted 14 years ago by pruntrut
A nice way to do sorting of a key on a multi-dimensional array - DavidG
0
2188
posted 14 years ago by satie83
In this purely constructed example, we create anonymous function and use call to invoke it on every object in an array. The main purpose of the anonymous function here is to add a print function to every object, which is able to print the right index...
0
2993
posted 14 years ago by hellowouter
Clever usage of apply allows you to use built-ins functions for some tasks that otherwise probably would have been written by looping over the array values. As an example here we are going to use Math.max/Math.min to find out the maximum/minimum valu...
0
2736
posted 14 years ago by hellowouter
If you want to use this in a class, change the last line to:
` return array_map(array($this, __FUNCTION__), $object ); `
0
1639
posted 14 years ago by jgomez
Removes duplicating elements from Array, containing only objects of Point class
0
3967
posted 14 years ago by romech
Easily breaks a string into an array of words.
*If your string has special characters such as latin, add those characters to the r var. Just like var r:RegExp = /[^\wçà áâãèéêìÃîòóôõùúûüÀÃÇÂÃÈÉÊÌÃÎÒÓÔÕÙÚÛÜ¡]+/...
0
4558
posted 14 years ago by izaiasdotcom
This method shuffles an array. This is the optimum implementation for such an algorithm - O(n).
0
1711
posted 14 years ago by fixpq
The usual way to shuffle an array uses the .sort() method with Math.round(Math.random())-0.5
This solution is highly biased based on the sort algorithm used by the browsers. A sort comparison operation has to fulfill the condition "if a>b then b<a"...
0
1671
posted 14 years ago by devnull69
This sorts a multi-dimensional array by one of the values in the array. Sorts in Desc order (most recent date first).
0
1970
posted 14 years ago by bitsculptor