$data = [
['id' => 1, 'field1' => 'Вася'],
['id' => 2, 'field1' => 'Петя'],
['id' => 3, 'field1' => 'Миша']
];
foreach ($data as $row) {
$stmt->execute($row);
}
или$data = [
1 => 'Вася',
2 => 'Петя',
3 => 'Миша'
];
foreach ($data as $id => $field1) {
$stmt->execute(['id' => $id, 'field1' => $field1]);
}
const deepEqual = (a, b) => {
if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {
return a === b;
}
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every(
(key) => bKeys.includes(key) && deepEqual(a[key], b[key]),
);
}
class A
{
private static array $instances = [];
public readonly int $value;
public function __construct(?int $value = null)
{
if ($value !== null) {
$this->value = $value;
static::$instances[] = $this;
}
}
public function summ(): int
{
return array_reduce(
static::$instances,
fn($acc, $cur) => $acc + $cur->value,
0
);
}
}
new A(2);
new A(3);
$summ = (new A())->summ();
print $summ; // 5
const p = new Promise(...).then(...).then(...).catch();
можно записать какconst p1 = new Promise(...);
const p2 = p1.then(...);
const p3 = p2.then(...);
const p4 = p3.catch(...);
$json = file_get_contents('php://input');
$data = json_decode($json);
axios.get(url[, config])