/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function in_array(d, b, a) { var c = "", a = !! a; for (c in b) if (a && b[c] === d) return !0; else if (!a && b[c] == d) return !0; return !1 }; // * example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']); // * returns 1: true // * example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'}); // * returns 2: false // * example 3: in_array(1, ['1', '2', '3']); // * returns 3: true // * example 3: in_array(1, ['1', '2', '3'], false); // * returns 3: true // * example 4: in_array(1, ['1', '2', '3'], true);
URL: http://phpjs.org/functions/in_array:432