<?php
class warehouse {
function __construct($id, $x, $y) {
$this->id = $id;
}
function getId() {
return $this->id;
}
}
class inventory_feed {
function __construct($id, $warehouse, $x) {
$this->id = $id;
$this->warehouse_id = $warehouse;
}
function getWarehouseId() {
return $this->warehouse_id;
}
}
$warehouse_1 = new warehouse(1, 100, [1,2,3,4]);
$warehouse_2 = new warehouse(2, 1100, [1,2,3,4]);
$warehouse_3 = new warehouse(3, 12000, [1,2,3,4]);
$warehouse_4 = new warehouse(4, 130000, [1,2,3,4]);
$warehouse_5 = new warehouse(5, 1400000, [1,2,3,4]);
$inventory_feed_1 = new inventory_feed(12, 1, "2as21332kjd");
$inventory_feed_2 = new inventory_feed(10, 2, "2123asagfrtsdd");
$inventory_feed_3 = new inventory_feed(11, 3, "2as1231sds2d");
$inventory_feed_4 = new inventory_feed(13, 4, "2as1231sds2d");
$inventory_feed_5 = new inventory_feed(14, 5, "2as1231sds2d");
$ifeeds = ["a" => $inventory_feed_1, "b" => $inventory_feed_2, "c" => $inventory_feed_3];
$warehouses = [$warehouse_1, $warehouse_2, $warehouse_3, $warehouse_4, $warehouse_5];
$warehouses,
function ($warehouse) use ($ifeeds) {
foreach($ifeeds as $ifeed_id => $ifeed) {
if ($ifeed->getWarehouseId() == $warehouse->getId()) {
return true;
}
}
return false;
});
PD9waHAKCmNsYXNzIHdhcmVob3VzZSB7CiAgICBmdW5jdGlvbiBfX2NvbnN0cnVjdCgkaWQsICR4LCAkeSkgewogICAgICAgICR0aGlzLT5pZCA9ICRpZDsKICAgIH0KICAgIGZ1bmN0aW9uIGdldElkKCkgewogICAgICAgIHJldHVybiAkdGhpcy0+aWQ7CiAgICB9Cn0KCmNsYXNzIGludmVudG9yeV9mZWVkIHsKICAgIGZ1bmN0aW9uIF9fY29uc3RydWN0KCRpZCwgJHdhcmVob3VzZSwgJHgpIHsKICAgICAgICAkdGhpcy0+aWQgPSAkaWQ7CiAgICAgICAgJHRoaXMtPndhcmVob3VzZV9pZCA9ICR3YXJlaG91c2U7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