This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks if a value exists in an array | |
* @param {mixed} needle : The searched value | |
* @param {array} haystack : The array | |
* @return {bool} | |
*/ | |
var in_array = (function (needle, haystack) { | |
return ( haystack.indexOf(needle) !== -1 ); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove all occurrences of a given value from an array | |
* @param {mixed} val : value to delete | |
*/ | |
Array.prototype.unset = function(val){ | |
var index; | |
while ( (index = this.indexOf(val)) !== -1 ) { | |
this.splice(index,1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns the level of depth of an array | |
* @param array $array | |
* @param integer $level : do not use, just used for recursivity | |
* @return int : depth | |
*/ | |
function array_depth($array, $level = 0) { | |
if ( ! $array ) |