To create a new array, use the following syntax:
arrayname = new Array()
Or you can use the shorthand form, as follows:
arrayname = 
In PHP, you could add a new element to an array by simply assigning it without specifying the element offset, like this:
$arrayname = "Element 1"; $arrayname = "Element 2";
push method to achieve the same thing, like
arrayname.push("Element 1") arrayname.push("Element 2")
This allows you to keep adding items to an array without having
to keep track of the number of items. When you need to know how many
elements are in an array, you can use the
length property, like this:
Alternatively, if you wish to keep track of the element locations yourself and place them in specific locations, you can use syntax such as this:
arrayname = "Element 1" arrayname = "Element 2"
Example 15-8 shows a simple script that creates an array, loads it with some values, and then displays them.
<script> numbers =  numbers.push("One") numbers.push("Two") numbers.push("Three") for (j = 0 ; j < numbers.length ; ++j) document.write("Element " + j + " = " + numbers[j] + "<br />") </script>