Version compl�te: jsB@nk » Snippet » Multi-Dimensional Array recherche
URL: https://www.javascriptbank.com/multi-dimensional-array-searching.html
Utilisez cette fonction pour prototype search
par le biais d'un tableau multidimensionnel. Simple mais efficace! Comprend des exemples.
Version compl�te: jsB@nk » Snippet » Multi-Dimensional Array recherche
URL: https://www.javascriptbank.com/multi-dimensional-array-searching.html
<script language="javascript">// Created by: Jonathan Fenocchi :: http://www.slightlyremarkable.com/// Search format:// ArraytoSearch.search (String search term [, Boolean exact match])//// Note: "ArraytoSearch" is an array variable. String search term is what// you want to find in that array. Boolean exact match can be set to true// or false. If you want to find an exact match, you can omit this argument// or send it as false. If you want to find an instance, you can send// this argument as true.//// Example: http://www.webdeveloper.com/forum/showpost.php?p=348195&postcount=22//Array.prototype.search = function(s,q){ var len = this.length; for(var i=0; i<len; i++){ if(this[i].constructor == Array){ if(this[i].search(s,q)){ return true; break; } } else { if(q){ if(this[i].indexOf(s) != -1){ return true; break; } } else { if(this[i]==s){ return true; break; } } } } return false;}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->