Difference between revisions of "PHPEX03"

From mi-linux
Jump to navigationJump to search
 
(8 intermediate revisions by one other user not shown)
Line 15: Line 15:
 
</pre>
 
</pre>
  
Your webpage will display
+
Your webpage should display:
  
 
<pre>
 
<pre>
Line 22: Line 22:
 
Mary
 
Mary
 
Thomas
 
Thomas
<pre>
+
</pre>
 +
 
 +
How do you sort alphabetically? Easy! Arrays can be sorted with a single command, see [http://www.php.net/manual/en/function.sort.php online documentation].
 +
 
 +
So your algorithm should:
 +
* read each name from the file, and insert them into an array
 +
* sort the array
 +
* loop through the sorted array and display each item on the screen.
 +
 
 +
Good luck!
 +
 
 +
'''Important: you should commit your mini-task code to your Git project.'''
 +
 
 +
= Ready to move on? =
 +
 
 +
When done, please proceed to the [[PHP110|next section]].

Latest revision as of 12:07, 20 September 2023

Main Page >> Web Application Development >> Workbook >> Mini-task 03

Use everything you have learnt this week to create a single webpage that will:

  • read a list of names from a text file
  • sort them alphabetically and display them on the screen.

So if your text file contains the following data:

Mary
Alix
Thomas
Bob

Your webpage should display:

Alix
Bob
Mary
Thomas

How do you sort alphabetically? Easy! Arrays can be sorted with a single command, see online documentation.

So your algorithm should:

  • read each name from the file, and insert them into an array
  • sort the array
  • loop through the sorted array and display each item on the screen.

Good luck!

Important: you should commit your mini-task code to your Git project.

Ready to move on?

When done, please proceed to the next section.