Assignment 3
: Arrays and Strings
Practice Programs:
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.
Answer :
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.
Answer :
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
Answer :
SET A:
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
Answer :
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
e) Traverse the elements in an
array in random order.
Answer :
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.
Answer :
SET B:
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
Answer :
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.
Answer :
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.
Answer :
SET C:
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.
Answer :
Assignment 3 : Arrays and Strings
Reviewed by technical_saurabh
on
March 18, 2021
Rating:

No comments:
Post a Comment