skip to main |
skip to sidebar
What’s the difference between sort(), assort() and ksort?
1. sort()
Sorts an array in alphabetical order based on the value of each element. The index keys will also be renumbered 0 to length - 1. This is used primarily on arrays where the indexes/keys do not matter.
2. asort()
Like the sort() function, this sorts the array in alphabetical order based on the value of each element, however, unlike the sort() function, all indexes are maintained, thus it will not renumber them, but rather keep them. This is particularly useful with associate arrays.
3. ksort()
Sorts an array in alphabetical order by index/key. This is typically used for associate arrays where you want the keys/indexes to be in alphabetical order.
No comments:
Post a Comment
If you are really interested about our blogger, Please Share your opinion here ...
If you Found Any Interviews in your reliable sources, Please Post the information through this Comment and It will be Published in our blogger. help every one to get a Job.