Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Coldfusion Limit result from array

Posted on 2004-10-13
5
Medium Priority
?
344 Views
Last Modified: 2013-12-20
I just want to grab the first FLTDURATION from array Arr_TotalResults. The following gives me a FLTDURATION for every item in the array. Is there a simple way to limit the result to just the first 'FLTDURATION' ?

<cfloop from="1" to="#arraylen(Arr_TotalResults)#" index="i"><cfoutput>(#Arr_TotalResults[i].FLTDURATION#)</cfoutput></cfloop>

Many thanks,
Michelle
0
Comment
Question by:mjacobs2929
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:kkhipple
ID: 12297173
<CFOUTPUT>
     #Arr_TotalResults[1]#
</CFOUTPUT>


This should give you the first value of the array. Now if FLT_DURATION is the first element, then this works. If FTL_DURATION is the fourth element in the array, then this works:

<CFOUTPUT>
     #Arr_TotalResults[4]#
</CFOUTPUT>


REFERENCE: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/arrayStruct3.htm
0
 

Author Comment

by:mjacobs2929
ID: 12297983
Sorry, this is actually an array of a structure, so I can't rely on 'FLTDURATION' always being at position 4, or whatever. Is it possible to get just the first occurance of 'FLTDURATION' from an array containing a structure?
0
 
LVL 10

Accepted Solution

by:
Mause earned 2000 total points
ID: 12299580
Hi

Width your code you loop over the array and get every FLTDURATION but this is not what you want!

To get the FLTDURATION of the first array position you do this:
<cfoutput>(#Arr_TotalResults[1].FLTDURATION#)</cfoutput>

Will this work for you?
or does every array value contains a different structure and you want the first FLTDURATION that is found in the array?

Let me know
Mause
0
 

Author Comment

by:mjacobs2929
ID: 12299646
Yep, that worked! Just wanted the first instance. I guess that shows how little I understand CF arrays or structures! :[
0
 
LVL 10

Expert Comment

by:Mause
ID: 12299654
NP

Glad I could help
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
Suggested Courses

963 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