1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Find all alt"" params from a string - I'm halfway there but need some help

Discussion in 'Programming' started by simplymatt, Oct 29, 2010.

  1. #1
    Here's what I have:

    <cfset StartText = 'alt="'>
     <cfset Start = FindNoCase(StartText, Cfhttp.FileContent, 1)>
     <cfset EndText = '" '>
     <cfset Length = Len(StartText)>
     <cfset End = FindNoCase(EndText, Cfhttp.FileContent, Start)>
     <cfset alt = Mid(Cfhttp.FileContent, Start+Length, End-Start-Length)>
    <strong>Alt:</strong> <cfoutput>#alt#</cfoutput><br />
    Code (markup):
    That gives me the first instance of alt="" that it comes across. What I need to do is loop it to return all instances of alt="" that it finds.

    Any help?

    Thanks in advance.
    simplymatt, Oct 29, 2010 IP
  2. simplymatt

    simplymatt Guest

    Likes Received:
    Best Answers:
    Trophy Points:
    Additionally, I have found that:

    <cfset result = reMatch("<img[^>]+>", Cfhttp.FileContent)>
    <cfdump var="#result#">
    will give me all the <img> from the page. However, I can't use <cfoutput> in place of <cfdump> as it is giving me an error.

    So close . . .
    simplymatt, Oct 29, 2010 IP
  3. cfStarlight

    cfStarlight Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    Cfoutput only outputs simple objects. reMatch returns an array (complex object). Loop through the array and output each item individually.

    <cfloop array="#yourArray#" index="elem">
    #elem# <br>
    cfStarlight, Oct 29, 2010 IP