PHP Taskbook Level 9.5

Задание 1

Given an array:

php[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Given a form with an input. A number is entered into the input. After sending the form, create a table filled with data from this array, containing as many columns as specified in the input.

Задание 2

Given an arbitrary two-dimensional array:

php[
  [11, 12, 13, 14, 15],
  [21, 22, 23, 24, 25],
  [31, 32, 33, 34, 35],
  [41, 42, 43, 44, 45],
  [51, 52, 53, 54, 55],
]

Zero out the elements of its main diagonal:

php[
  [ 0, 12, 13, 14, 15],
  [21,  0, 23, 24, 25],
  [31, 32,  0, 34, 35],
  [41, 42, 43,  0, 45],
  [51, 52, 53, 54,  0],
]
Задание 3

Make a function that will set the correct form of a noun after a number. Here's how the function should work:

phpfunc(1, 'apple', 'apples', 'apples'); // will bring out '1 apple'
func(2, 'apple', 'apples', 'apples'); // will bring out '2 apples'
func(3, 'apple', 'apples', 'apples'); // will bring out '3 apples'
func(4, 'apple', 'apples', 'apples'); // will bring out '4 apples'
func(5, 'apple', 'apples', 'apples'); // will bring out '5 apples'

Here is an example for two-digit numbers:

phpfunc(11, 'apple', 'apples', 'apples'); // will bring out '11 apples'
func(12, 'apple', 'apples', 'apples'); // will bring out '12 apples'
func(21, 'apple', 'apples', 'apples'); // will bring out '21 apple'
func(23, 'apple', 'apples', 'apples'); // will bring out '23 apples'

Our function should work for numbers of any length:

phpfunc(1223421, 'apple', 'apples', 'apples'); // will bring out '1223421 apple'