I have an array containing friends list of a user on Facebook.
I have to display that list and provide a text field on the top of the list to enter first letter of any of his/her friends name. When the user enters a letter in the text field, the program should display only the names that start with the entered letter, all other names should vanish.
In addition the names should be sorted alphabetically.
How do I perform this task?
First I have to ask are you using javascript or anything to filter or is it just server side code using php?
Aside from that here’s the steps to how I would do it just on the php side.
1) Sort the entire list of all the user’s friends so the full array is in order. Take a look at this http://www.php.net/manual/en/function.sort.php.
2) When the user inputs their single letter, you simply just have to:
Display the small array as it will already be sorted from having the master list already sorted.