array_intersect returns 严重性:4096 消息:class stdClass 的对象无法转换为字符串 CodeIgniter
array_intersect returns Severity: 4096 Message: Object of class stdClass could not be converted to string CodeIgniter
我有两个数组都有多个值和 std Class 对象,我想使用 'array_intersect' 但它显示 "Severity: 4096 Message: Object of class stdClass could not be converted to string"
控制器代码:
$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
虽然它给出了所需的结果但是有很多错误,我附上了它的屏幕截图,请看一下 scoll 条(很长的错误)
这段代码returns想要的结果..
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; }
我有两个数组都有多个值和 std Class 对象,我想使用 'array_intersect' 但它显示 "Severity: 4096 Message: Object of class stdClass could not be converted to string"
控制器代码:
$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
虽然它给出了所需的结果但是有很多错误,我附上了它的屏幕截图,请看一下 scoll 条(很长的错误)
这段代码returns想要的结果..
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; }