hey, i just started doing php a couple days ago. maybe i'm just a moron, but i can't seem to do something...
i really hope that this wasn't asked before, because i can't seem to find it on forums.
but say i have a multi-dimensional array of writings. like:
$books = array(
array (
title=>"Romeo and Juliet",
author=>"William Shakespeare",
path=>"romeo_and_juliet.txt",
),
array (
title=>"Of Human Bondage",
author=>"W. Somerset Maugham",
path=>"of_human_bondage.txt",
),
array (
title=>"Sons and Lovers",
author=>"D.H. Lawrence",
path=>"sons_and_lovers.txt",
),
);
or something like that. (i just whipped up a quick example)
is there a function to sort it by a certain element, but keep each array intact? like, could i sort it alphabetically by title, and get (inside the array):
array (
title=>"Of Human Bondage",
author=>"W. Somerset Maugham",
path=>"of_human_bondage.txt",
),
array (
title=>"Romeo and Juliet",
author=>"William Shakespeare",
path=>"romeo_and_juliet.txt",
),
array (
title=>"Sons and Lovers",
author=>"D.H. Lawrence",
path=>"sons_and_lovers.txt",
),
you know? so each array itself is still the same, but because i sorted it by title, $books[0] is now "Of Human Bondage," $books[1] is now "Romeo and Juliet," etc...
or sort by author, and have Sons and lovers first because it is by D.H. Lawrence, have Of Human Bondage second because it is by W. Somerset Maugham, etc...
ideas, anyone?
i apologize beforehand if the answer to this is somewhere already...