Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

DEPARTMENT OF COMPUTER STUDIES

(Applications Development and Emerging


Technologies)

PRE-SUMMATIVE ASSESSMENT

3
PHP ARRAYS AND FUNCTIONS

Student Name / Group Micah Mackenzie P. Lozano


Name:
Name Role
Members (if Group):

Section:
Professor:
LABORATORY ACTIVITY

1. USING ARRAYS, create a program using PHP that will contain 10 different names,
images, age, birthday and contact number then display it in alphabetical order (use array
sorting), with integration of HTML and CSS.

Sample Output:

Applications Development and Emerging Technologies Page 2 of 13


Input:

Applications Development and Emerging Technologies Page 3 of 13


Output:

Applications Development and Emerging Technologies Page 4 of 13


Applications Development and Emerging Technologies Page 5 of 13
2. Using ARRAYS, create a program using PHP that will contain 10 different numbers and
get the sum, difference, product and quotient of all values in the array.

Sample Output:

Applications Development and Emerging Technologies Page 6 of 13


Input:

Applications Development and Emerging Technologies Page 7 of 13


Applications Development and Emerging Technologies Page 8 of 13
Output:

3. USING USER DEFINED FUNCTION


 Create a program that will get the sum, difference, product and
quotient of 3 given parameters.
Example your_function(param1,param2,param3)

Sample Output:

Applications Development and Emerging Technologies Page 9 of 13


Input:

Applications Development and Emerging Technologies Page 10 of 13


Applications Development and Emerging Technologies Page 11 of 13
Output:

Applications Development and Emerging Technologies Page 12 of 13


VII. QUESTION AND ANSWER

1. For your understanding what is an array?


 In my understanding an array is a data structure that is able to store one or more similar types of
values in a single value.
2. Differences between simple variable and a variable array?
 A simple variable can contain only a single value, under that variable name, while a variable array
can contain more than one value at a time under same variable name.
3. Give an instance where you can use or apply an array.
 An instance where you can use or apply an array say if you want to store 100 numbers or records
instead of defining 100 variables for that you can easily define an array with 100 lengths.
4. What are the different array sorting? describe each.
 sort() - sort arrays in ascending order
 rsort() - sort arrays in descending order
 asort() - sort associative arrays in ascending order, according to the value
 ksort() - sort associative arrays in ascending order, according to the key
 arsort() - sort associative arrays in descending order, according to the value
 krsort() - sort associative arrays in descending order, according to the key
5. What is Function?
 In a larger program, a function is a piece of code. A particular task is performed by the function.
The benefits of using functions are: Minimizing duplication of code, decomposing complex
problems into simpler bits, improving consistency of the code, reuse of code and information
hiding. The keyword of the function is followed by the function name with round brackets. Between
the curly brackets lies the body of the feature. We say we're calling for a feature. When we call a
function, the statements are executed within the body of the function.
6. Give the different usage of functions.
 There are different usages for functions. Like the built-in functions are the functions that are
already in the program and it could just be directly called from within the script and perform a
particular task. There are also user-defined functions, these are block of statements that you can
use repeatedly in the program that you are making. You just need to call the function and this
would be executed that task that you assigned to it. You can use functions also to perform
arguments which makes you program much easier.

Applications Development and Emerging Technologies Page 13 of 13

You might also like