[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Coldfusion ArrayLen() Problem

Posted on 2004-10-21
2
Medium Priority
?
581 Views
Last Modified: 2013-12-24
I have an array of a structure from which I am already successfully outputting the correct number of results (where Arr_TotalResults[i].SOURCE IS "Gemini", which is outputting 5 rows because only 5 elements EQ Gemini). I now need to get the array length MINUS those which do not have a structure key SOURCE IS "Gemini". I thought the code below would do this because it is already working on the output, however, it's giving me the full length of the array (which is 11) and still including those which do not match 'Gemini'. Please can someone tell me what I'm doing wrong here??

Many thanks,
Michelle


<cfloop from="1" to="#arrayLen(Arr_TotalResults)#" index="i">
 <cfif Arr_TotalResults[i].SOURCE IS "Gemini">
  <cfset js_numBoth=arrayLen(Arr_TotalResults)>
 </cfif>
</cfloop>

<cfoutput>
 #js_numBoth#
</cfoutput>

0
Comment
Question by:mjacobs2929
2 Comments
 
LVL 11

Accepted Solution

by:
hart earned 2000 total points
ID: 12369711
just do this

<cfset nGeminiCtr = 0>
<cfloop from="1" to="#arrayLen(Arr_TotalResults)#" index="i">
   <cfif Arr_TotalResults[i].SOURCE IS "Gemini">
     <cfset nGeminiCtr = IncrementValue(nGeminiCtr)>
   </cfif>
</cfloop>

Now

<cfoutput>
For Gemini Total Count  EQ #nGeminiCtr#<br>
For The total Array Length - #ArrayLen(TotalResults)#<br>
For The count with out Gemini - #Evaluate(ArrayLen(TotalResults)-nGeminiCtr)#<br>
</cfoutput>

Regards
hart
0
 

Author Comment

by:mjacobs2929
ID: 12369836
Brilliant!
Thanks so much for the speedy response!
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

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

Media Temple is thrilled to announce the launch of our new Partner Program, specifically designed to empower digital agencies and adtech platforms by offering white-glove support and exclusive hosting enhancements to optimize their sites and their c…
This installment of Make It Better gives Media Temple customers the latest news, plugins, and tutorials to make their VPS hosting experience that much smoother.
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
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

591 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