WebPro2023 Assignment1
WebPro2023 Assignment1
Problem 1: Give an appropriate example for each of the following array functions,
specify or print the input value(s) and print the outputs in a file called array.php:
1. is_array() 9. array_pop()
2. in_array() 10. array_values()
3. array_merge() 11. array_map()
4. array_keys() 12. array_slice()
5. array_key_exists() 13. array_diff()
6. array_shift() 14. array_search()
7. array_unshift() 15. array_reverse()
8. array_push() 16. implode()
Problem 2: Give an appropriate example for each of the following string functions, print
the input value(s) and print the outputs in a file called string.php:
1. strlen() 11. strtok() 21. addslashes()
2. substr() 12. trim() 22. strip_tags()
3. strpos() 13. ltrim() 23. stripcslashes()
4. chr() 14. rtrim() 24. htmlentities()
5. ord() 15. chop() 25. htmlspecialchars()
6. str_split() 16. number_format() 26. str_word_count()
7. str_replace() 17. strtoupper() 27. explode()
8. str_repeat() 18. strtolower() 28. md5()
9. strrev() 19. ucfirst() 29. sha1()
10. str_pad() 20. ucwords() 30. crypt()
Note:
1. the examples in above problmes should be in the following format:
Input: P1: "Hello World";
Function: strlen()
Output: 11
2. For printing arrays in readable layout, define a dump() function in a separate file called
utilities.php, then include the utilities in both array.php and string.php.
Page 1 of 3
Instructor: Imad Hadi Hasan Issued: 2023-02-22
Example1:
Input: let input_array = [
["name": "Zara Azad", "age": 20, "email": "[email protected]"],
["name": "Ahmed Rafiq", "age": 25, "email": "[email protected]"],
["name": "Darbaz Ghafur", "age": 28, "email": "[email protected]"],
];
Output:
# Name Age Email
1 Zara Azad 20 [email protected]
2 Ahmed Rafiq 25 [email protected]
3 Darbaz Ghafur 28 [email protected]
Example2:
Output:
# Name Phone
1 Zara Azad +964000110011
2 Ahmed Rafiq +964000223311
3 Darbaz Khudhr +964000440444
Page 2 of 3
Instructor: Imad Hadi Hasan Issued: 2023-02-22
Example 3:
Input: $menu = [
"home" => ["title"=>"Home", "link"=>"home.php"],
"about" => ["title"=>"About", "link"=>"about.php"],
"departments"=> [
"title"=>"Departments",
"link"=>"#",
"children" => [
"software" => ["title"=>"Software Department" , "link"=>"software.php"],
"civil" => ["title"=>"Civil Department" , "link"=>"civil.php"],
"electrical"=> ["title"=>"Electrical Department", "link"=>"elect.php"],
]
],
];
Output
• Home
• About
• Departments
o Software Department
o Civil Department
o Electrical Department
• Please note that, when you submit your assignment’s file, create a folder with
your full name like this “G-firstname-midname-lastname” and zip it twice.
Note: G: is your group A or B