dongluzhi5208 2019-03-05 21:33
浏览 111
已采纳

array_intersect返回严重性:4096消息:类stdClass的对象无法转换为字符串CodeIgniter

I got two arrays both have multiple values with std Class objects, I want to use 'array_intersect' but it shows "Severity: 4096 Message: Object of class stdClass could not be converted to string"

Controller Code:

    $AlreadyInsertedList = $this->bill->GetBillsbyDate($Givendate); //array1
    $NotInserted = $this->admin->GetACustomersbyArea($areaid);       //array2
    $finallist = NULL;        //finalarray
    $finallist = array_intersect($AlreadyInsertedList,$allcustomersbyarea); //Line number 88 
    //$array = json_decode(json_encode($finallist)); //already tried not working

Although it is giving the required results but with a lot of errors, I'm attaching a screen shot of it, do have a look at the scoll bar (a long length of errors) enter image description here

  • 写回答

1条回答 默认 最新

  • duanmei1946 2019-03-06 06:39
    关注

    This code returns the desired results..

    function ary_diff( $ary_1, $ary_2 ) {   // compare the value of 2 array   // get differences that in ary_1 but not in ary_2   // get difference that in ary_2 but not in ary_1   // return the unique difference between value of 2 array   $diff = array();
    
      // get differences that in ary_1 but not in ary_2   foreach ( $ary_1 as $v1 ) {
        $flag = 0;
        foreach ( $ary_2 as $v2 ) {
          $flag |= ( $v1 == $v2 );
          if ( $flag ) break;
        }
        if ( !$flag ) array_push( $diff, $v1 );   }
    
      // get difference that in ary_2 but not in ary_1   foreach ( $ary_2 as $v2 ) {
        $flag = 0;
        foreach ( $ary_1 as $v1 ) {
          $flag |= ( $v1 == $v2 );
          if ( $flag ) break;
        }
        if ( !$flag && !in_array( $v2, $diff ) ) array_push( $diff, $v2 );   }
    
      return $diff; }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致