<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>ARRAYINSERTAT</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">ARRAYINSERTAT</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Inserts a value into an array. Array elements whose indexes are equal to or greater than the new position are incremented by one. The array length increases by one. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
True, on successful completion. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
Array functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>ArrayInsertAt(array, position, value)
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
ArrayDeleteAt; "Functions for XML object management" in Chapter&#160;35, "Using XML and WDDX," in ColdFusion MX Developer's Guide
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX:
</p>
<ul>

<li>Changed behavior: this function can be used on XML objects.</li>

<li>Changed thrown exceptions: this function can throw the InvalidArrayIndexException error.</li>
</ul>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
To apply the ArrayInsert() function to a multidimensional array, you must specify all but the last index in the array parameter. For example, the following code inserts an element at myarray[2][4]:
</p>
<pre>&lt;cfset ArrayInsertAt(myarray[2], 4, "test")&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Throws</span>
<p>
If this function attempts to insert an element at position 0, or specifies a value for position that is greater than the size of array, this function throws an InvalidArrayIndexException error. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;h3&gt;ArrayInsertAt Example&lt;/h3&gt;&lt;p&gt;
&lt;!--- create a new array ---&gt;
&lt;cfset DaysArray = ArrayNew(1)&gt;
&lt;!--- populate an element or two ---&gt;
&lt;cfset DaysArray[1] = &quot;Monday&quot;&gt;
&lt;cfset DaysArray[2] = &quot;Tuesday&quot;&gt;
&lt;cfset DaysArray[3] = &quot;Thursday&quot;&gt;
&lt;!--- add an element before position 3 ---&gt;
&lt;p&gt;Add an element before position 3:
   &lt;cfoutput&gt;#ArrayInsertAt(DaysArray,3,&quot;Wednesday&quot;)#&lt;/cfoutput&gt;
&lt;p&gt;Now output the array as a list:
&lt;cfoutput&gt;#ArrayToList(DaysArray)#&lt;/cfoutput&gt;
&lt;!--- The array now has four elements. Element 3, &quot;Thursday&quot;, has become 
element four ---&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="ARRAY">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ARRAY</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Name of an array</p>

  </td>
  </tr>
  </table>
</div>
<div id="POSITION">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">POSITION</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Index position at which to insert value </p>

  </td>
  </tr>
  </table>
</div>
<div id="VALUE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">VALUE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Value to insert </p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
