$userDice = mt_rand(1,6);
$computerDice = mt_rand(1,6);
// для PHP 7
switch ($userDice <=> $computerDice) {
case -1:
$message = "У компьютера выпало {$computerDice}, а у юзера {$userDice}. Выигрыш компьютера";
break;
case 0:
$message = "У юзера выпало {$userDice}, а у компьютера {$computerDice}. Ничья!";
break;
case 1:
$message = "У юзера выпало {$userDice}, а у компьютера {$computerDice}. Выигрыш юзера";
break;
}
echo $message; $data = [...]; // ваши данные
$data = array_filter($data, function($item) {
return $item['x'] == 2;
});
$data = array_map(function($item) {
return $item['y'];
}, $data);
$max = max($data);$data = [...]; // ваши данные
$max = max(array_map(
function($item) {
return $item['y'];
},
array_filter($data, function($item) {
return $item['x'] == 2;
})
)); $dbh->prepare('INSERT INTO `message`(`email_otvet`, `messageh`, `messaget`) VALUES (?, ?, ?)')->execute([
$emailotveta, $messageh, $messaget
]); $a = MyClass::getInstance();
$b = MyClass::getInstance();class C
{
private $p;
public function getProperty() {
if (is_null($this->p)) {
$this->p = ...
}
return $this->p;
}
}class C
{
private static $instance;
private function __constructor() {
// init
}
public static function getInstace() {
if (is_null($this->instance)) {
$this->instance = new self();
}
return $this->instance;
}
}