function array_diff_assoc_recursive($array1, $array2) {
$difference=array();
foreach($array1 as $key => $value) {
if( is_array($value) ) {
if( !isset($array2[$key]) || !is_array($array2[$key]) ) {
$difference[$key] = $value;
} else {
$new_diff = array_diff_assoc_recursive($value, $array2[$key]);
if( !empty($new_diff) )
$difference[$key] = $new_diff;
}
} else if( !array_key_exists($key,$array2) || $array2[$key] !== $value ) {
$difference[$key] = $value;
}
}
return $difference;
}
$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/omnipay
league/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"