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; }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?