У меня есть 2 многомерных массива, мне нужно вычислить расхождение между ними, я пробовал их сравнить функцией array_diff но выводит ошибку, как я понял потому что array_diff принимает одномерный массив, мои массивы ниже
array ( 0 => array ( 'id' => '1', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '1', 'actionfield02' => NULL, 'action' => 'I', 'code' => '1', 'description' => 'Manufacturer 1', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => '2019-02-19 20:02:45', ), 1 => array ( 'id' => '2', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => NULL, 'actionfield02' => NULL, 'action' => NULL, 'code' => NULL, 'description' => NULL, 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), 2 => array ( 'id' => '3', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '3', 'actionfield02' => NULL, 'action' => 'I', 'code' => '2', 'description' => 'Manufacturer 2', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), )array ( 0 => array ( 'id' => '1', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '1', 'actionfield02' => NULL, 'action' => 'I', 'code' => '1', 'description' => 'Manufacturer 1', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => '2019-02-19 20:02:45', ), 1 => array ( 'id' => '2', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => NULL, 'actionfield02' => NULL, 'action' => NULL, 'code' => NULL, 'description' => NULL, 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), 2 => array ( 'id' => '3', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '3', 'actionfield02' => NULL, 'action' => 'I', 'code' => '2', 'description' => 'Manufacturer 2', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), )array ( 0 => array ( 'id' => '1', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '1', 'actionfield02' => NULL, 'action' => 'I', 'code' => '1', 'description' => 'Manufacturer 1', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => '2019-02-19 20:02:45', ), 1 => array ( 'id' => '2', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => NULL, 'actionfield02' => NULL, 'action' => NULL, 'code' => NULL, 'description' => NULL, 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), 2 => array ( 'id' => '3', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '3', 'actionfield02' => NULL, 'action' => 'I', 'code' => '2', 'description' => 'Manufacturer 2', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), )array ( 0 => array ( 'id' => '1', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '1', 'actionfield02' => NULL, 'action' => 'I', 'code' => '1', 'description' => 'Manufacturer 1', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => '2019-02-19 20:02:45', ), 1 => array ( 'id' => '2', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => NULL, 'actionfield02' => NULL, 'action' => NULL, 'code' => NULL, 'description' => NULL, 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), 2 => array ( 'id' => '3', 'tablename' => 'ITEMANUFACTURER', 'actionfield01' => '3', 'actionfield02' => NULL, 'action' => 'I', 'code' => '2', 'description' => 'Manufacturer 2', 'rtiprice' => NULL, 'colorcode' => NULL, 'colordescr' => NULL, 'size' => NULL, 'sizethesi' => NULL, 'category' => NULL, 'sezon' => NULL, 'sex' => NULL, 'age' => NULL, 'mnfid' => NULL, 'composition' => NULL, 'eshopdisable' => NULL, 'actionremarks' => NULL, 'iteremain' => NULL, 'addvalidate' => '1 ', 'actiondate' => NULL, ), )
Второй массив
array ( 0 => array ( 'ID' => 1, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '1', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '1', 'Description' => 'Manufacturer 1', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => '2019-02-19 20:02:44.647', 'AddValidate' => '1 ', ), 1 => array ( 'ID' => 2, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => NULL, 'ACTIONFIELD02' => NULL, 'ACTION' => NULL, 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 2 => array ( 'ID' => 3, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '3', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '2', 'Description' => 'Manufacturer 2', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 3 => array ( 'ID' => 4, 'TABLENAME' => '5', 'ACTIONFIELD01' => '6', 'ACTIONFIELD02' => '7', 'ACTION' => '8', 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), )array ( 0 => array ( 'ID' => 1, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '1', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '1', 'Description' => 'Manufacturer 1', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => '2019-02-19 20:02:44.647', 'AddValidate' => '1 ', ), 1 => array ( 'ID' => 2, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => NULL, 'ACTIONFIELD02' => NULL, 'ACTION' => NULL, 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 2 => array ( 'ID' => 3, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '3', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '2', 'Description' => 'Manufacturer 2', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 3 => array ( 'ID' => 4, 'TABLENAME' => '5', 'ACTIONFIELD01' => '6', 'ACTIONFIELD02' => '7', 'ACTION' => '8', 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), )array ( 0 => array ( 'ID' => 1, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '1', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '1', 'Description' => 'Manufacturer 1', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => '2019-02-19 20:02:44.647', 'AddValidate' => '1 ', ), 1 => array ( 'ID' => 2, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => NULL, 'ACTIONFIELD02' => NULL, 'ACTION' => NULL, 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 2 => array ( 'ID' => 3, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '3', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '2', 'Description' => 'Manufacturer 2', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 3 => array ( 'ID' => 4, 'TABLENAME' => '5', 'ACTIONFIELD01' => '6', 'ACTIONFIELD02' => '7', 'ACTION' => '8', 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), )array ( 0 => array ( 'ID' => 1, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '1', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '1', 'Description' => 'Manufacturer 1', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => '2019-02-19 20:02:44.647', 'AddValidate' => '1 ', ), 1 => array ( 'ID' => 2, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => NULL, 'ACTIONFIELD02' => NULL, 'ACTION' => NULL, 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 2 => array ( 'ID' => 3, 'TABLENAME' => 'ITEMANUFACTURER', 'ACTIONFIELD01' => '3', 'ACTIONFIELD02' => NULL, 'ACTION' => 'I', 'Code' => '2', 'Description' => 'Manufacturer 2', 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), 3 => array ( 'ID' => 4, 'TABLENAME' => '5', 'ACTIONFIELD01' => '6', 'ACTIONFIELD02' => '7', 'ACTION' => '8', 'Code' => NULL, 'Description' => NULL, 'RtIPrice' => NULL, 'ColorCode' => NULL, 'ColorDescr' => NULL, 'Size' => NULL, 'SizeThesi' => NULL, 'Category' => NULL, 'Sezon' => NULL, 'Sex' => NULL, 'Age' => NULL, 'Mnfid' => NULL, 'Composition' => NULL, 'EshopDisable' => NULL, 'IteRemain' => NULL, 'ActionRemarks' => NULL, 'ActionDate' => NULL, 'AddValidate' => '1 ', ), )
Вот здесь решение вашей задачи
https://www.codeproject.com/Questions/780780/PHP-Finding-differences-in-two-multidimensional-ar
function array_diff_assoc_recursive($array1, $array2)
{
foreach($array1 as $key => $value)
{
if(is_array($value))
{
if(!isset($array2[$key]))
{
$difference[$key] = $value;
}
elseif(!is_array($array2[$key]))
{
$difference[$key] = $value;
}
else
{
$new_diff = array_diff_assoc_recursive($value, $array2[$key]);
if($new_diff != FALSE)
{
$difference[$key] = $new_diff;
}
}
}
elseif(!isset($array2[$key]) || $array2[$key] != $value)
{
$difference[$key] = $value;
}
}
return !isset($difference) ? 0 : $difference;
}
Воспользуйтесь методом array_udiff()
$diff = array_udiff( $old_array, $new_array, function ($a, $b) { return $a != $b; } );
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
На сайте на WordPress есть зарегистрированный новый тип записи и таксономий
При переносе сайта с локалки на хостинг, появилась непонятная проблема, при открытии страницы в админ-панели модулей, появляется ошибка
Доброго времени суток!