Highlighted

Nested loops with arrays

Engaged ,
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

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>

Views

193

Likes

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

Nested loops with arrays

Engaged ,
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

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>

Views

194

Likes

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
Feb 15, 2016 0
Engaged ,
Feb 15, 2016

Copy link to clipboard

Copied

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>

Likes

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
Reply
Loading...
Feb 15, 2016 0