function getAnswer($valut) {
return match($valut) {
1 => 'нет',
2 => 'двумя',
3 => 'тремя',
4 => 'пятью',
5 => 'десятью',
};
}
echo getAnswer(1) . ' пальцами';
$currentYear = date("Y");
$currentDate = new DateTime();
$bday = get_field('Birthday', $user); // maybe it is like '06-08'
$bday = new DateTime($currentYear . '-' . $bday);
if ($bday <= $currentDate) {
$interval = $bday->diff($currentDate);
echo $interval->format('%R%a дней');
}
<form method="post">
не хватает action
, куда шлются данные $numberStrings = '3,4,5';
$array = explode(',', $numberStrings);
$numberNumbers = array_map(fn(string $val) => (int) $val, $array);
var_dump($numberNumbers);
/*
array(3) {
[0]=>
int(3)
[1]=>
int(4)
[2]=>
int(5)
}
*/
$array = [
'mainarr' => [
'arr2' => [
0 => [
'attr' => [
'name' => 'name0'
],
],
1 => [
'attr' => [
'name' => 'name1'
],
],
2 => [
'attr' => [
'name' => 'name2'
],
],
3 => [
'attr' => [
'name' => 'name3'
],
],
],
],
];
$array2 = [
'mainarr' => [
'arr2' => [
'attr' => [
'name' => 'name2'
],
]
]
];
var_dump(count(array_column($array['mainarr']['arr2'], 'attr'))); //4
var_dump(count(array_column($array2['mainarr']['arr2'], 'attr'))); //0
$filename = $_FILES["filename"]["name"];
move_uploaded_file($_FILES["filename"]["tmp_name"], "avatar/$filename");
$query = $connection->prepare("UPDATE table_user SET avatar = :avatar WHERE user_id = :user_id");
$query->bindParam(':avatar', $filename);
$query->bindParam(':user_id', $user_id);
$query->execute();
$query = 'SELECT * FROM bonusesstat WHERE dateo BETWEEN ? AND ?';
$execParams[] = $firstDate;
$execParams[] = $lastDate;
R::exec($query, $execParam);
$output = file_get_contents('your_file.txt', FALSE, NULL, $begin, $end);