1 Reply Latest reply on Jul 19, 2007 11:35 AM by Newsgroup_User

    array from array using split

    jonnybennett Level 1
      for (i=0;i<_global.searchSearchArray.length;i++){
      this["searchResultsArray"+i]=searchSearchArray .split("|");}

      _root.testerText.text=searchResultsArray1[1];

      I am geting undefined.

      It is to do with the:

      this["searchResultsArray"+i]=

      because if I change this to

      searchResultsArray1=

      then it will giv me an answer however it obviously isn't doing what I want, because I need it to be split into new arrays. Thanks if you understand or to any responders.!!
        • 1. Re: array from array using split
          Level 7
          is this what you are looking for?... searchResultsArray ends up being an
          array of arrays... ( a 2D array )

          searchResultsArray = new Array();
          searchSearchArray = new Array();

          searchSearchArray[0] = "a|b|c|d";
          searchSearchArray[1] = "e|f|g|h";

          for ( i = 0; i < searchSearchArray.length; i++ )
          {
          searchResultsArray = searchSearchArray.split("|");
          }

          trace( searchResultsArray[0][0] )
          output is "a"

          trace( searchResultsArray[1][0] )
          output is "e"

          trace( searchResultsArray[1][3] )
          output is "h"

          jonnybennett wrote:
          > for (i=0;i<_global.searchSearchArray.length;i++){
          > this["searchResultsArray"+i]=searchSearchArray .split("|");}
          >
          > _root.testerText.text=searchResultsArray1[1];
          >
          > I am geting undefined.
          >
          > It is to do with the:
          >
          > this["searchResultsArray"+i]=
          >
          > because if I change this to
          >
          > searchResultsArray1=
          >
          > then it will giv me an answer however it obviously isn't doing what I want,
          > because I need it to be split into new arrays. Thanks if you understand or to
          > any responders.!!
          >