I have a php array like :
myarr[1] = "1",
myarr[2] = "1.233",
myarr[3] = "0",
myarr[4] = "2.5"
the values are actually strings but i want this array to be sorted numerically, also considering float values and maintaining index association.
Please help me out.
Thanks
You can use the normal
sortfunction. It takes a second parameter to tell how you want to sort it. ChooseSORT_NUMERIC.Example:
prints
Update: For maintaining key-value pairs, use
asort(takes the same arguments), example output: