Assignment:

PHP

Assignment :3

ARRAYS AND STRINGS


Practice Questions


Q.1 : Write a PHP Script to define an array. Find the element from the array that matches the given value using the appropriate search function.



Q.2 : Write a PHP script to count the total number of vowels (a,e, i,o,u) from the string. Show the occurrences of each vowel from the string.



Q.3 : Write PHP program to perform the following operations on Indexed Array: a) Check the array element is positive or negative b) Calculate the average of array elements c) Calculate the sum of array elements



Set A


Q.1 : Write PHP program to perform the following operations on Indexed Array: a) Union of two arrays b) Traverse the array elements in random order



Q.2 : Write a PHP program to perform the following operations on an associative array: a) Display the elements of an array along with the keys. b) Display the size of an array c) Delete an element from an array from the given index. d) Reverse the order of each element’s key-value pair



Q.3 : Write a PHP Script for the following: a) Declare and Display a multidimensional Array. b) Search and display a specific element from a Multidimensional array.



Set B


Q.1 : Write a PHP script to perform the following operations on string : i) Compare string 2 with string3. ii) Convert all the strings to Upper case iii) Convert all the strings to Lowercase



Q.2 : Write a PHP script to perform the following operations on string : i) Convert each word of a string to Lowercase and Uppercase. ii) Find the first and last occurrence of string2 in string1.



Q.3 : Write a menu-driven program in PHP to perform the following operations on associative arrays: i) Sort the array by values (changing the keys) in ascending, descending order. ii) Also, sort the array by values without changing the keys. iii) Find the intersection of two arrays. iv) Find the union of two arrays.



Set C


Q.1 :Write a PHP script to perform the following operations on string : i) Replace the string2 by string3 in string1. ii) Reverse and display the string.