Solved

Coldfusion ArrayPrepend Question

Posted on 2004-10-06
1
383 Views
Last Modified: 2013-12-16

How can I use ArrayPrepend() to add an element to a 2d array?

<!--- Set Route-Airport-Country Array --->
<cfset countToo=js_route_airport_country.recordCount>
<cfloop index="i" from="1" to="#countToo#">
 <cfset airportArray[i][1]='#js_route_airport_country.country_desc[i]#'>
 <cfset airportArray[i][2]='#js_route_airport_country.airport_desc[i]#'>
 <cfset airportArray[i][3]='a#js_route_airport_country.airport_code[i]#'>
 <cfset airportArray[i][4]='#DateFormat(js_route_airport_country.start_date[i], "yyyymm")#'>
 <cfset airportArray[i][5]='#DateFormat(js_route_airport_country.end_date[i], "yyyymm")#'>
</cfloop>
   <cfdump var="#airportArray#">


Many thanks,
Michelle
0
Comment
Question by:mjacobs2929
1 Comment
 
LVL 4

Accepted Solution

by:
reggi635 earned 125 total points
ID: 12238946
ArrayAppend works good for a Single dim array.
ArrayInsetAt would server ur purpose.
Something like this :
<cfscript>
    appendValues = ArrayNew(1);
    appendValues[ 1 ] = "d1";
    appendValues[ 2 ] = "d2";
    appendValues[ 3 ] = "d3";
    appendValues[ 3 ] = "d4";
    appendValues[ 3 ] = "d5";
    ArrayInsertAt(airportArray, 1, appendValues);
</cfscript>

Even this should work as well
<CFSET airportArray[ ArrayLen(airportArray) + 1 ][ 1 ] = "d1">
so on .......

REGGI

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now