Sorting an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Sorting an array

Post by malcolmboston »

I have an array that looks like this:

Code: Select all

Array
(
    [0] => Array
        (
            [productName] => Isla Mujeres
            [productStockCode] => 72870
            [productColour] => Raw Denim
            [productOnlinePrice] => 154.99
            [productQuantity] => 1
            [productSize] => Sml
            [productCategoryType] => Jeans
            [productBrandName] => Artful Dodger
        )

    [1] => Array
        (
            [productName] => Isla Mujeres
            [productStockCode] => 72870
            [productColour] => Raw Denim
            [productOnlinePrice] => 154.99
            [productQuantity] => 1
            [productSize] => Sml
            [productCategoryType] => Jeans
            [productBrandName] => Artful Dodger
        )

    [3] => Array
        (
            [productName] => Shark Camo
            [productStockCode] => 72889
            [productColour] => Pink
            [productOnlinePrice] => 119.99
            [productQuantity] => 1
            [productSize] => Sml
            [productCategoryType] => Track Top
            [productBrandName] => Artful Dodger
        )

)
i would like to sort the array so that it re-orders the numbers to 0, 1, 2, 3 and so on.

What do i need to be using?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Which numbers?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

the items in the original array are labelled "0, 1, 3" i would like them to be automatically re-numbered starting from 0
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply