Home TechnologyProgramming Subscribe to RSS

What Are Arrays?

Answer Question

2 Answers - Sort by: Date | Rating

    Arrays are basically lists.  So instead of a variable being just one of something, it can instead be a list of things.

    An associative array is a special kind of list, where you are able to reference each item in the list by a predefined name.  For example, if you have a list of telephone numbers, you could use the person's name as the 'key' in the associative array, to reference their phone number.  In PHP you would write something like $phone_number = $contacts['John'] to get John's phone number.
    0 0

    John 

    answered 7 months ago

      Think of an array as a list of data items, each item being able to be referenced by its place in the list (array).  So the array CITIES could be made up of the items (names in this case) Chicago, Detroit, Madison, and Indianapolis.  A program could go through the list and do something with it.  This is called a one dimensional array.  If one wanted pairs of items, a two dimensional array could be created.  And so forth.

      An array can also be thought of as a file within a program.  Indeed one could populate an array from a file, but an array's contents can also be hard-coded.  Or be filled bt prompting the user for the data.  And then something is done with it.

      Arrays can be sorted, low to high or high to low depending on what's needed.  Sometimes the programming/scripting language has this built in, but earlier languages required programmers to that manually.
      0 0

      Alvin47 

      answered 7 months ago

        More

           
           

          Ask a Question via Twitter

          Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

          Blurtit Store

          Get T-shirts, hoodies, caps and more at the Blurtit store

          Blurtit International