PHP arrays
The following problems need to be written in PHP - you can combine
multiple into one program or do them separately your call.
Problem #1:
- Set up an array using the style $info[0] = 'whatever';. It should
have at least four elements..
- Set up another array using the style $info = array('whatever',...
- Append an element to both arrays
- Loop through each of the arrays using a for
- Loop through each of the arrays using a foreach
- Unset one of the elements of the array
- Check to see if it is there using isset
Problem #2:
- Set up a two dimensional array where the rows the months
of the year and the columns stand for standard expenses like
rent, electric, water, insurance, taxes,credit card etc. And
put the estimated expense in the cell. You can limit it to a few
months and a few expenses to get a more manageable array.
- Now access the array by inputing the number for the month
and the number for the standard expense and returning the estimated
expense from the cell.
- For example:
| 0 | 1 | 2 |
0 | 100 | 200 | 75 |
1 | 50 | 200 | 20 |
2 | 150 | 200 | 50 |
3 | 100 | 200 | 90 |
Problem #3:
- Set up two arrays the first should associate the course number (use
the real number) to a course name (I shortened) and the second should
associate the course name with the professor.
- Put in a course number and extract the name of the course and the professor
- Next use a foreach to extract and print all course names with
their associated professor.