$products = [
[
'product_id' => 102966,
'price' => 11,
],
[
'product_id' => 102967,
'price' => 22,
]
];
$attributes = [
[
'product_id' => 102966,
'attr_name' => 'Диагональ;Длительность ролика',
'attr_value' => '2";1 мин, 2 мин, 3 мин, 5 мин',
],
[
'product_id' => 102967,
'attr_name' => 'Выходы;Диагональ;Дополнительная информация',
'attr_value' => 'HDMI;2.7";рабочие диапазоны',
],
];
$products = array_map(function($product) use ( $attributes ) {
$attribute = array_filter($attributes, function($attribute) use ( $product ) {
return $attribute['product_id'] === $product['product_id'];
});
return array_merge($attribute ? current($attribute) : [], $product);
}, $products);
print_r($products);
$('#go').click(function(){
let term = $('#term').val().split(' '),
text = 'Планшет Apple iPad купить недорого',
reg = term.reduce((acc, item) => acc.replace(new RegExp(item, "gi"), "<strong>$&</strong>"), text)
$('#rez').html(reg);
});
league/omnipayleague/omnipay
"use strict";
var handleChange = function handleChange(e) {
return function (dispatch) {
dispatch({
type: PROMO_CODE,
payload: e.target.value
});
};
};
class entity {
isDead = false;
heals = 100;
damage = 10;
strike(entity, damage) {
if (!this.isDead) {
entity.heals -= damage;
if (entity.heals <= 0) {
this.isDead = true
console.log(entity, 'is dead');
}
}
}
}
class heroEntity extends entity {
heals = 150;
damage = 15;
}
class mobEntity extends entity {
}
const hero = new heroEntity(),
mob = new mobEntity();
hero.strike(mob, 100); // mobEntity {isDead: false, heals: 0, damage: 10} "is dead"
function invalidRegex($regex)
{
if(preg_match($regex, null) !== false)
{
return '';
}
$errors = array(
PREG_NO_ERROR => 'Code 0 : No errors',
PREG_INTERNAL_ERROR => 'Code 1 : There was an internal PCRE error',
PREG_BACKTRACK_LIMIT_ERROR => 'Code 2 : Backtrack limit was exhausted',
PREG_RECURSION_LIMIT_ERROR => 'Code 3 : Recursion limit was exhausted',
PREG_BAD_UTF8_ERROR => 'Code 4 : The offset didn\'t correspond to the begin of a valid UTF-8 code point',
PREG_BAD_UTF8_OFFSET_ERROR => 'Code 5 : Malformed UTF-8 data',
);
return $errors[preg_last_error()];
}