US: 800.995.PLUM UK: 0845.355.3330
- What is IVR?
- IVR Products & Services
- Free Consultation
- Plum IVR Surveys
- About Us
from the Plum Voice IVR Glossary
An array is a a data type offered by most programming languages that provides indexed access into a collection of variables. Arrays usually serve as computer implementations of the mathematical concepts of the vector or matrix. They also serve as the foundational type for more complicated structures such as strings, lists, and tables.
var numbers = [4, 8, 15, 16, 23, 42]; alert(numbers); // get the 1st element: "4" numbers = 17; // sets the 4th element, which was 16, to be 17 numbers.push(43); // pushes 43 onto the end of the array alert(numbers.length); // how big is the array now? "7" alert(numbers.shift()); // removes the first element of the array and returns it // result: "4" alert(numbers.join(' ')) // joins the elements of the array with a space // result: "8 15 17 23 42 43"
The following demonstrates the same operations on an array in PHP. PHP also uses zero-based indexing.
<?php $numbers = array(4, 8, 15, 16, 23, 42); echo $numbers; // get the 1st element: "4" $numbers = 17; // sets the 4th element, which was 16, to be 17 $numbers = 43; // pushes 43 onto the end of the array // shorthand for array_push($numbers, 43); echo count($numbers); // how big is the array now? "7" echo array_shift($numbers); // removes the first element of the array and returns it // result: "4" echo implode(' ', $numbers); // joins the elements of the array with a space // result: "8 15 17 23 42 43"
<foreach/> tag. Here is an example of a prompt being constructed from an array of movie titles (not a complete VXML document):
<script> var movies = ['The Godfather', 'High Fidelity', 'Raiders of The Lost Ark']; </script> <!-- ... --> <prompt> Please select one of the following movies. <break time="500ms"/> <foreach item="movie" array="movies"> <value expr="movie"/> <break time="500ms"/> </foreach> </prompt>
|© 2013 The Plum Group, Inc.|