Мои входные массивы:
Код: Выделить всё
$rela = [
['Sale'],
['Customer'],
['Sale_Fee'],
['Sale'],
['Location'],
['Sale'],
['Sale'],
['Sale_Iten'],
['Product'],
['Customer'],
['Location'],
['Sale_Iten'],
['Sale_Fee'],
['Region']
];
$db = [
['Customer'],
['Customer_Type'],
['Fee_Type'],
['Location'],
['Location_Type'],
['Period'],
['Product'],
['Product_Type'],
['Region'],
['Sale'],
['Sale_Fee'],
['Sale_Iten'],
['State']
];
Код: Выделить всё
function maxEntities($rela, $db){
$maxenty = array();
$found = false;
foreach ($rela as $valor1) {
print $valor1[0] . " | ";
}
print "
";
foreach ($db as $valor2) {
print $valor2[0] . " | ";
}
$maxenty = array_diff($rela[0], $db[0]);
print "
";
foreach ($maxenty as $valor) {
print " " . $valor;
}
}
Код: Выделить всё
Sale | Customer | Sale_Fee | Sale | Location | Sale | Sale | Sale_Iten | Product | Customer | Location | Sale_Iten | Sale_Fee | Region |
Customer | Customer_Type | Fee_Type | Location | Location_Type | Period | Product | Product_Type | Region | Sale | Sale_Fee | Sale_Iten | State |
SaleNULL
Код: Выделить всё
PeriodКак могу ли я решить свою проблему?
Я также пробовал использовать foreach, но он тоже выдает неправильный результат.
Код: Выделить всё
foreach ($rela as $relaV) {
foreach ($db as $dbV) {
if ($dbV[0] == $relaV[0]) {
$found = true;
}
if (!$found) {
$found = false;
$maxenty[] = $dbV[0];
}
}
}
Код: Выделить всё
Customer
Customer_Type
Fee_Type
Location
Location_Type
Period
Product
Product_Type
Region
Подробнее здесь: https://stackoverflow.com/questions/242 ... ther-2d-ar
Мобильная версия