Modifying Array Elements - why


#1


UNIT 4: Arrays
Lesson 6: Modifying Array Elements

I am not having an issue with this exercise per se, rather my question has to do with real world application of modifying array elements. Why would you do this? In what cases would this be practical or useful?

Thanks
steve


      <?php
        $languages = array("HTML/CSS", "JavaScript", "PHP", "Python", "Ruby");
         $languages[3] = "Not a language";
        echo $languages[3];
      ?>

Why would I want to do that? Why would I want to modify the array element 'Python'?


#2

I guess really organizing,

Let's say you have
Eggs, Milk, Flour, Baking powder, and bananas.

Obviously these all cost something at a grocery store so they have a value

Organizing them like

Eggs = this amount
and milk = this amount

Getting prices at a grocery store I guess...

Another could be if you are trying to work with different companies and you need to know the values with priorities and everything

Maybe this helps?


#3

@steveros,
I picked two Articles, so you can get the feel....
http://stackoverflow.com/questions/4441139/when-to-use-an-object-or-an-array-in-javascript
http://stackoverflow.com/questions/16433397/difference-between-enqueue-and-dequeue