Easiest problem evar.

    Date: 06/09/05 (PHP Community)    Keywords: php, xml

    So, I'm writing this PHP script, and I've got an array named $filesArr full of a random list of files.

    I can not for the life of me make $listOfFilesInOrder (or whatever) have four entries from $filesArr, then logo.jpg, then four more from $filesArr, then logo.jpg and so on, until the end of $filesArr, then there needs to be one last logo.jpg at the end.

    The final goal is to get it into an XML file (with stuff before and after that's not dynamic) that looks like:




    // which will be logo.jpg


    ... and so on, with, of course, logo.jpg being every fourth one, and the last one when the list runs out.

    I've tried this three different not-f*cking-working ways and I'm just frustrated and tired. Should I just scrap this logical stuff and put it all in a big recursive foreach() loop or something? I'm worried about optimization, 'cause this script gets called first thing when the site gets hit.

    Hell, if I can just get someone to explain the damn logic, that would help. I'm the world's most lame coder, having a lame problem, with a lame language. It's a lame shame.

    If it helps, the project is a slideshow thing for this client.

    I've got a Flash slideshow-type application, built with half-stolen-functions-half-written-actionscript. I can't dynamically get a list of files to pick from, 'cause I just don't think AS does that. So, I figure to get the list from an external XML file.

    But, then, I was thinking, why not make that XML file dynamically generated so that I don't have to edit this guy's site every time he wants to add pictures. He can just drop a picture in the directory, and the next time someone hits the site, it'll be added to the rotation. But, evidentally, you can't do that with AS either, (or I can't figure out how) so I'm putting this PHP script together (for the app to call) to get a list of all the files, randomize it, put them into order (above), then write the whole thing to an XML file for the Flash app to use.

    The workhorse part of the flash app is done. I'm gonna loadMovie it into the site framework part, which won't take a second to put together. The hold up is my inability to make PHP do a simple f*cking task in a logical way. If I can get this script WORKING, then I can spend only a few more hours, put this thing up, and pick up my check quick-as-a-bunny.

    Obviously the hole in this solution to the problem is the fact that the script runs every time someone hits the page. I'm open to suggestions on how to solve that little conundrum. Should I just include it as a tool and have this guy run it whenever he updates? That would solve the optimization problem, but then it wouldn't be different for each user. Maybe set up a cron job to do the change once a day or something.

    Source: http://www.livejournal.com/community/php/305274.html

« help with mysql functions... || PHP doesn't wanna... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home