element
MooTools: takeOut and putBack methods
Sometimes you don’t want to replace an element with another one, you just want a placeholder, so you can put it back later. I wrote takeOut and putBack to help out with that. Element.implement({ takeOut: function(elementType) { var elementType = ($type(elementType) == "string" ? elementType: "span"); this.placeholder = ($defined(this.placeholder) ? this.placeholder : new Element(elementType).setStyle("display", "none").addClass("takenOut_"+this.get("id"))); [...]
Random Element from Array in PHP
There is a function called array_rand but it only returns the key for a random element in an array. So here’s a quick function for you that can do it all in just a couple of lines. function array_random($array) { return $array[array_rand($array)]; } Yes, the word array does appear four times, but that isn’t to [...]