WITH RECURSIVE `cte` AS (
SELECT `id`, `pid`, `name`, 0 AS `level`
FROM `table`
UNION SELECT `p`.`id`, `p`.`pid`, `p`,`name`, `cte`.`level` + 1 AS `level`
FROM `cte`
JOIN `table` AS `p` ON `p`.`id` = `cte`.`pid`
)
SELECT `id`, `name`, `level`
FROM `cte`
ORDER BY `level`
$arTab = ['call', 'fields'];
$arr = [
['id' => 'call', 'communication' => '123'],
['id' => 'fields', 'communication' => '111'],
['id' => 'garden', 'communication' => '4544'],
];
$result = array_values(array_filter(
$arr,
static fn(array $item): bool => !in_array($item['id'], $arTab),
));
var_export($result);
// array (
// 0 => array (
// 'id' => 'garden',
// 'communication' => '4544',
// ),
//)
<?php
$x = 400;
$y = 0.75;
$z = 1.5;
$test = ($x + 2 * $y - ($x / 2 + 2 * $z)) / 2;
print $test;
// 99.25
$json = file_get_contents('php://input');
var_dump(new DateTimeImmutable('yesterday'));
//object(DateTimeImmutable)#1 (3) {
// ["date"]=> string(26) "2023-05-03 00:00:00.000000"
// ["timezone_type"]=> int(3)
// ["timezone"]=> string(3) "UTC"
//}
var_dump(new DateTimeImmutable('1 day ago'));
//object(DateTimeImmutable)#1 (3) {
// ["date"]=> string(26) "2023-05-03 05:14:22.254741"
// ["timezone_type"]=> int(3)
// ["timezone"]=> string(3) "UTC"
//}