This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Worker{ | |
private $name; | |
private $age; | |
private $salary; | |
public __construct() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Driver extends NewWorker{ | |
private $drivingExperience; | |
private $drivingCategory; | |
public function getDrivingExperience() | |
{ | |
return $this->drivingExperience; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function Factorial_Recursive($number){ | |
$number = (int)$number; | |
if($number < 0){ | |
return false; | |
}elseif($number >= 0 && $number <= 1 ){ | |
return 1; | |
}else{ | |
return $number * Factorial_Recursive($number - 1); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function check_array(array $arr){ | |
$output = ''; | |
foreach($arr as $element){ | |
if($element != 0 && ($element %3 == 0 || $element %7 == 0)){ | |
$output .= $element.','; | |
} | |
} | |
return substr($output, 0, -1); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Вывести числа Фибоначи, где кол-во цифр задано параметром $n | |
* | |
* На выходе строка к примеру - '0,1,1,2,3,5 и тд.' | |
* | |
* Числа Фибоначи где каждое последующее число | |
* образуется путем сложения двух предыдущих. | |
* Пример: | |
* 0,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Найти максимальное значение в одноуровневом массиве | |
* На входе array(2,5,3,5,6,7,8,9,25,24,18) | |
* | |
* Должно быть 333 | |
*/ | |
function testMinMax1(array $arr){ | |
if($arr){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* На входе массив чисел $array и число $min | |
* Нам нужно удалить все значения, что меньше $min | |
* | |
* На входе array(2,5,3,5,6,7,8,9,25,24,18,26,27,28,29,30,31) | |
* Передаем $min = 9 | |
* На выходе должно быть array(9,25,24,18,26,27,28,29,30,31) | |
*/ | |
function testMinMax3(array $array, $min){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function counter(array $array,$multi = 0){ | |
$count = 0; | |
foreach($array as $val){ | |
if($multi){ | |
if(is_array($val)){ | |
$count += counter($val,1); | |
}else{ | |
++$count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Найти максимальное значение в многоуровневом массиве | |
* На входе array(1,2,array(400,12,13),3,4,array(21,22,23,array(231),),) | |
* На выходе 400 | |
*/ | |
function array_max($array) | |
{ | |
static $max; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Нужно: обрезать строку и добавить в конец '...', если та больше заданной длинны. | |
* | |
* На входе два параметра | |
* $string - строка | |
* $lenght - длинна | |
* | |
* Пример: | |
* $tring = 'John Doe' |
OlderNewer