Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthoreplawless
    • CommentTimeAug 15th 2006
     permalink
    Ok, weird question. If I'm going about this all wrong somebody please tell me :s

    I'm reading in information from a bunch of xml documents, and storing 4 pieces of information (name, id, price, description) from each in an associative array ($item['name'], $item['id'] etc.). I then added each $item to another array, $items. I want to be able to sort these records by either name or price, so I wrote a quicksort function, but I've hit a snag.

    How would I go about switching the order of two items in an associative array in php? Is that even possible? How would I sort the xml data from multiple xml files, otherwise?
    • CommentAuthordhayes
    • CommentTimeAug 16th 2006
     permalink
    if the item id is the key, use ksort.. you can use array_map to filter the elements through a callback function. it's difficult to understand exactly what it is you're tryinig to accomplish without knowing more.. hopefully this helps a little.
    • CommentAuthorJack
    • CommentTimeAug 16th 2006
     permalink
    I'm pretty sure there's are functions in php that do exactly what you want. I don't think writing your own sort function is a good use of your time.

    try the php docs to start
    • CommentAuthorn0n@m3
    • CommentTimeAug 18th 2006
     permalink
Add your comments
    Username Password
  • Format comments as (Help)