• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Nested loops with arrays

Enthusiast ,
Feb 15, 2016 Feb 15, 2016

Copy link to clipboard

Copied

This is my current and outer cfloop. How many nested cfloops do I need to get to data.current_version.en.text field? My guess is two loops but I'm not sure about specifying the value for the "to" in the cfloop.

<cfif structKeyExists(cfData, 'data')>

        <cfoutput>

            <cfloop index="i" from ="1" to="#arrayLen(cfData.data)#">               

            <h1>#cfData.data.searchTitle.en#</h1>

            <p>#cfData.data.current_version.en.text#</p>

            </cfloop>

        </cfoutput>

    </cfif> 

And this is what the struct looks like.

ColdFusion-Array.png

Views

300

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Feb 15, 2016 Feb 15, 2016

Okay, got it work.

<cfif structKeyExists(cfData, 'data')>

        <cfoutput>

            <cfloop index="i" from ="1" to="#arrayLen(cfData.data)#">

                <h1>#cfData.data.name#</h1>

                <p>#cfData.data.current_version.en.text#</p>

            </cfloop>

        </cfoutput>

</cfif>

Votes

Translate

Translate
Enthusiast ,
Feb 15, 2016 Feb 15, 2016

Copy link to clipboard

Copied

LATEST

Okay, got it work.

<cfif structKeyExists(cfData, 'data')>

        <cfoutput>

            <cfloop index="i" from ="1" to="#arrayLen(cfData.data)#">

                <h1>#cfData.data.name#</h1>

                <p>#cfData.data.current_version.en.text#</p>

            </cfloop>

        </cfoutput>

</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation