console.dir(value); // Array(2) // Вам это ничего не говорит?
const arr = [20, 27];
console.log(arr.includes(27)); // true
// К тому же если бы это был объект (ассоциативный массив) в виде обычного массива (наличие порядка и длины), то...
const obj = {
0: 20,
1: 27,
length: 2
};
console.log(Array.prototype.includes.call(obj, 27)); // true
// Определение типа
const getType = something => Object.prototype.toString.call(something).slice(8, -1);
console.log(getType([1, 2, 3, 4, 5])); // Array
console.log(getType({})); // Object
console.log(getType(12)); // Number
console.log(getType("iamevg")); // String
// Перевод объекта в массив.
const obj = {
0: 20,
1: 27,
2: 54,
3: 12,
4: 67
};
console.log(Array.of(...(Object.entries(obj)).map(item => item[1]))); // [20, 27, 54, 12, 67]
console.log(Array.of(...Object.values(obj))); // тоже самое, только ES2017
Из папки default копирую код в свой шаблон, но поле не появляется.
Если поле это обычный input, то как его программно обработать, чтобы реализовать скидки?
"HIDE_COUPON" => "N"
Я предполагаю, что выделится ровно столько, сколько элементов перечислено в списке
# переопределяем страницы ошибок
ErrorDocument 400 /error.php?err=400
ErrorDocument 401 /error.php?err=401
ErrorDocument 402 /error.php?err=402
ErrorDocument 403 /error.php?err=403
ErrorDocument 404 /error.php?err=404
ErrorDocument 500 /error.php?err=500
ErrorDocument 502 /error.php?err=502
ErrorDocument 404 /
class SimpleClass
{
public function __invoke()
{
return $this;
}
public function stdout($string)
{
echo $string;
return $this;
}
}
class SimpleClass
{
public function __invoke(string $string = PHP_EOL): self
{
echo $string;
return $this;
}
}
if ($auth instanceof User) {
// user related code
} elseif ($auth instanceof Server) {
// server related code
} else {
throw new SomeException()
}
$stock = [
["id"=>1, "ver"=>13, "name"=>"gta v"],
["id"=>2, "ver"=>48, "name"=>"gta sa"],
["id"=>3, "ver"=>119, "name"=>"chess"],
];
$total = 0;
foreach($stock as $v) $total += $v["ver"];
$rnd = rand(1, $total);
$run = 0;
foreach($stock as $v) {
$run += $v["ver"];
if( $rnd <= $run) break;
}
$prizeName = $v["name"];