Bansaw Posted April 9, 2012 Share Posted April 9, 2012 I have an array I want to define in Php and then sort it. I am pretty new to Php and don't know the syntax or what funcs to use. Here's the array I want: user_email, user_name, hours_worked_per_week, total_earned There will be about 120 users, and I want to sort them ascending alphabetically on user_email Quote Link to comment Share on other sites More sharing options...
scootstah Posted April 9, 2012 Share Posted April 9, 2012 Are you getting this information from a database? If so you can sort them right in the query with the ORDER BY statement. Quote Link to comment Share on other sites More sharing options...
Bansaw Posted April 9, 2012 Author Share Posted April 9, 2012 Its not from a database. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted April 9, 2012 Share Posted April 9, 2012 Its not from a database. It should be. How is the data saved? Please don't say to a .txt file. Quote Link to comment Share on other sites More sharing options...
Bansaw Posted April 9, 2012 Author Share Posted April 9, 2012 Someone is just inputting it on screen Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted April 9, 2012 Share Posted April 9, 2012 Someone is just inputting it on screen The data needs to be stored somewhere. How will there be 120 users if the data is not stored? Quote Link to comment Share on other sites More sharing options...
scootstah Posted April 9, 2012 Share Posted April 9, 2012 Someone is just inputting it on screen So someone is typing out 120+ user's info and then inputting it? Are they importing it from a CSV or XML or something? What are you doing with it after they input it? Quote Link to comment Share on other sites More sharing options...
Bansaw Posted April 9, 2012 Author Share Posted April 9, 2012 thanks, let's just say , for arguments sake, that I need to define an array with these elements: user_email, user_name, hours_worked_per_week, total_earned How do I define that array, and then how do I sort if ascending alpha on user_email? ... how the info gets into the array and what happens to it afterwards, let's leave to the side for the moment. Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 9, 2012 Share Posted April 9, 2012 thanks, let's just say , for arguments sake, that I need to define an array with these elements: user_email, user_name, hours_worked_per_week, total_earned How do I define that array, and then how do I sort if ascending alpha on user_email? ... how the info gets into the array and what happens to it afterwards, let's leave to the side for the moment. Let's not do that. The reason is that understanding where the data is coming from and what the ultimate disposition of that data can have significant impact on the "best" solution. One thing that really irritates me is when someone on these forums asks for a solution without providing all the relevant information. Then, once a solution is provided, they provide some tidbit of information that they *thought* was not pertinent but which, consequently, completely changes the solution needed. You don't even state "how" the user is inputting the information or how it is being received. Is the user entering data into individual fields for each piece of data for each user? Is there a csv or some other type of file input? And, again, what are you planning to DO with this data. having a user enter 120+ records of data for the sole purposes of sorting it and displaying it on screen without actually saving it sounds pretty worthless. By the way, if this is a homework problem, which I'm thinking it is, we will be glad to help, but you have to at least show some attempt at the problem. Quote Link to comment Share on other sites More sharing options...
algidDes702 Posted April 9, 2012 Share Posted April 9, 2012 i would have to agree with Pycho on this. there are many different ways to manage the data and process it how you are asking that depend on how its being retrieved/entered and used. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.