Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我没有使用数组_diff获得精确的输出_Php_Wordpress - Fatal编程技术网

Php 我没有使用数组_diff获得精确的输出

Php 我没有使用数组_diff获得精确的输出,php,wordpress,Php,Wordpress,这是一个经过编辑的表单,我在其中根据应用程序id获取数据。 在这里,我要做的就是从数据库中获取旧数据(保存前)并保存到变量中 保存后,我将获取数据库中更新的新数据 $edit_app_id =$_POST['Application_ID']; //getting old data based on edit_app_id; $old_data = $wpdb->get_row("SELECT company,collaborateM

这是一个经过编辑的表单,我在其中根据应用程序id获取数据。
在这里,我要做的就是从数据库中获取旧数据(保存前)并保存到变量中

保存后,我将获取数据库中更新的新数据

     $edit_app_id =$_POST['Application_ID'];
            //getting old data based on edit_app_id;
            $old_data = $wpdb->get_row("SELECT company,collaborateMS,ARM64_Board,collaboration_Details,special_requirements,Status,Application_Comments FROM wp3_AXC where Application_ID='$edit_app_id' ") ;
            print_r($old_data);
            $result = $wpdb->update($table_name, $item, array('id' => $item['id']));


            if ($result) {
                $message = __('Item was successfully updated', 'custom_table_example');
                $new_data = $wpdb->get_row("SELECT company,collaborateMS,ARM64_Board,collaboration_Details,special_requirements,Status,Application_Comments FROM wp3_AXC where Application_ID='$edit_app_id' ") ;
                print_r($new_data);
                //comparing  2 results(old_data vs new_data )
                $edit_result=array_diff($old_data,$new_data);
                print_r($edit_result);
结果:

$old_data : stdClass Object ( [company] => i [collaborateMS] => Join Estuary Development [ARM64_Board] => 2 [collaboration_Details] => i [special_requirements] => i [Status] => Pending [Application_Comments] => h ) 

$new_data : stdClass Object ( [company] => j [collaborateMS] => Estuary on new ARM64 Hardware [ARM64_Board] => 0 [collaboration_Details] => j [special_requirements] => j [Status] => Pending [Application_Comments] => j )
我得到了上述结果中提到的输出

我需要比较两者并得到变化

我已经使用了数组。\u diff我可以使用这个吗


谁能帮我提前谢谢

数组_diff用于两个数组之间。您正在对象之间使用它。谢谢!!!我通过将对象转换为数组得到了答案。$edit_result=array_diff((数组)$old_data,(array)$new_data);变量转储($edit\u result);数组_diff用于两个数组之间。您正在对象之间使用它。谢谢!!!我通过将对象转换为数组得到了答案。$edit_result=array_diff((数组)$old_data,(array)$new_data);变量转储($edit\u result);