2

all I want to do is sort an array, ascending, numerically. I have an array with values like:

Array(
    [0] = > card12.jpg
    [1] = > card16.jpg
    [2] = > card4.jpg
    [2] = > card1.jpg
    [2] = > card2.jpg
    [2] = > card3.jpg
)

The array has 16 values in it. I try to use sort($myArray); but it sorts it like card1 then card11, card 12...

This is really giving me a hard time. Can you give me any solutions to sort this array from card1 to card16.

1 Answer 1

2

Use natsort

natsort($myArray);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.