I have a PHP class and want to compare the data using two arrays according like the code below.
But, here I want to show out the difference data of both arrays.
I have tried the code below but it is not working and I'm stuck of this.
<?php
class TestClass{
public $fool = 'hehe';
public $fool2 = 'huhu';
public $fool3 = 'haha';
public $fool4 = 'haha';
public function __toString()
{
return $this->fool;
return $this->fool2;
return $this->fool3;
return $this->fool4;
}
}
$arr1 = array();
$class = new TestClass;
$class ->fool='one day';
$class ->fool2 ='test';
array_push($arr1,$class);
$arr2 = array();
$class2 = new TestClass;
$class2 ->fool ='one day';
$class2 ->fool2 ='different test';
array_push($arr2,$class2);
echo print_r($arr1).'<br/>';
echo print_r($arr2).'<br/>';
$result=array_diff($arr1,$arr2);
print_r($result);
?>