Posted By

mattkenefick on 05/19/08


Tagged

array index String find in of


Versions (?)

Array: Find


 / Published in: ActionScript
 

  1. Array.prototype._find = function(str,matchCase,dive) {
  2. /*
  3. * This returns the index of a find in an array
  4. * Note: Finds only ONE EXACT occurrence. Use _findAll for all occurrences.
  5. */
  6.  
  7. var ary_length = this.length;
  8. if(typeof(str)!="string") matchCase = true;
  9.  
  10. for (var i:Number=0;i < ary_length; ++i) {
  11. if( matchCase == true ){
  12. if( dive ) {
  13. if( this[i][dive] == str ) return i;
  14. }else{
  15. if( this[i] == str ) return i;
  16. }
  17. }else{
  18. var strL = str.toLowerCase();
  19. if( dive ) {
  20. if( this[i][dive].toLowerCase() == strL ) return i;
  21. }else{
  22. if( this[i].toLowerCase() == strL.toLowerCase() ) return i;
  23. }
  24. }
  25. }
  26. return false;
  27. }// End Function

Report this snippet  

You need to login to post a comment.