I want to sort this array alphabetically with the basename of the file but I want to keep the entire link. Using natcasesort it will sort the links with the http… in it.
I’ve tried natcasesort(basename($var)); but this doesn’t seem to work.
I can’t use substr because the size of the link and file names change.
Anyone have any ideas? I need to keep the link part because I need to link it later on and the paths aren’t constant.
Ah, that might be better than what I was doing. I had worked around the issue by putting the URL in the key of the array and the basename of the file as the value for that key.
It would probably be wiser to use (only) strnatcasecmp() within your cmp() function. It would behave more like Ryan wants, and saves you (needlessly) trying too hard to return -1, 0 or 1.