• # May 3, 2009 at 4:21 pm

    I have a set of questions that are located in a XML file. Using php, I need to pull the questions from the XML file and shuffle the order of the questions each time they are displayed to the user.

    What is the best way to implement this?

    Please be specific in your instructions and syntax because I am fairly new to php programming?

    Thank you!

    # May 3, 2009 at 9:20 pm

    If JavaScript is an option, I recently used James Padolsey’s DOM shuffler to shuffle questions on a quiz thingy for a client:

    I’m sure there is a PHP way to, which is probably smarter, but I’m not super hot with my PHP skillz =)

    # May 4, 2009 at 5:21 pm

    Hi Chris,

    Thank you for the information!


    # September 10, 2013 at 10:28 am
    # September 10, 2013 at 10:29 am


    In php, one of the options would be to store the questions in an array and the use shuffle() function to assist in doing what you trying to achieve.

    $question_array = array("Qa","Qb","Qc","Qd","Qe");
    //Shuffle the array of questions
    //print out the arrays to your screen or you may opt to save them yet to another array or variable for later use
    # September 11, 2013 at 12:57 am

    This reply has been reported for inappropriate content.

    To add to @migotn, do you have the ability to change how they’re stored, or is it a set format that you’re getting from somewhere?

    Depending on the answer to that question, the beginnings are different from @migotn, but the ending is pretty much the same: You’ll want to get the questions into an array and then use the shuffle()-function.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.