I've two arrays $a
and $b
containing 'user details' in arrays.
Following is the structure of it(i.e. output of print_r()
)
print_r($a);
Array
(
[0] => Array
(
[user_id] => 109
[profile_page_id] => 0
[user_name] => profile-109
[full_name] => Hiten Patel
[gender] => 0
[user_image] =>
[is_invisible] => 0
[user_group_id] => 6
[language_id] =>
[profile_image] => http://app.campusknot.com/theme/frontend/foxplus/style/default/image/noimage/profile_100.png
)
[1] => Array
(
[user_id] => 1585
[profile_page_id] => 0
[user_name] => profile-1585
[full_name] => Sushil Kadam
[gender] => 0
[user_image] => 1585%s.jpg
[is_invisible] => 0
[user_group_id] => 7
[language_id] =>
[profile_image] => http://app.campusknot.com/file/pic/user/1585_100_square.jpg
)
[2] => Array
(
[user_id] => 185
[profile_page_id] => 0
[user_name] => profile-185
[full_name] => Perceus Mody
[gender] => 1
[user_image] => 185%s.peg
[is_invisible] => 0
[user_group_id] => 6
[language_id] =>
[profile_image] => http://app.campusknot.com/file/pic/user/185_100_square.peg
)
[3] => Array
(
[user_id] => 196
[profile_page_id] => 0
[user_name] => profile-196
[full_name] => Ira Hampton
[gender] => 1
[user_image] => 2014/11/24c4a6835e667b67b82cea3666841ac7%s.jpg
[is_invisible] => 0
[user_group_id] => 6
[language_id] =>
[profile_image] => http://app.campusknot.com/theme/frontend/foxplus/style/default/image/noimage/profile.png
)
[4] => Array
(
[user_id] => 244
[profile_page_id] => 0
[user_name] => profile-244
[full_name] => Hiten Patel
[gender] => 2
[user_image] => 244%s.cza
[is_invisible] => 0
[user_group_id] => 7
[language_id] =>
[profile_image] => http://app.campusknot.com/file/pic/user/244_100_square.cza
)
)
The second array is as follows :
print_r($b);
Array
(
[0] => Array
(
[user_id] => 244
[profile_page_id] => 0
[user_server_id] => 0
[user_name] => profile-244
[full_name] => Hiten Patel
[gender] => 2
[user_image] => 244%s.cza
[is_invisible] => 0
[user_group_id] => 7
[language_id] =>
)
[1] => Array
(
[user_id] => 1585
[profile_page_id] => 0
[user_server_id] => 0
[user_name] => profile-1585
[full_name] => Sushil Kadam
[gender] => 0
[user_image] => 1585%s.jpg
[is_invisible] => 0
[user_group_id] => 7
[language_id] =>
)
)
Now I want to compare the two arrays $a and $b
and finally I want refined array $a
which will not contain common array elements as follows(the array keys should start from 0 and keep on increasing by 1).
print_r($a); //after refinement, the desired output array
Array
(
[0] => Array
(
[user_id] => 109
[profile_page_id] => 0
[user_name] => profile-109
[full_name] => Hiten Patel
[gender] => 0
[user_image] =>
[is_invisible] => 0
[user_group_id] => 6
[language_id] =>
[profile_image] => http://app.campusknot.com/theme/frontend/foxplus/style/default/image/noimage/profile_100.png
)
[1] => Array
(
[user_id] => 185
[profile_page_id] => 0
[user_name] => profile-185
[full_name] => Perceus Mody
[gender] => 1
[user_image] => 185%s.peg
[is_invisible] => 0
[user_group_id] => 6
[language_id] =>
[profile_image] => http://app.campusknot.com/file/pic/user/185_100_square.peg
)
[2] => Array
(
[user_id] => 196
[profile_page_id] => 0
[user_name] => profile-196
[full_name] => Ira Hampton
[gender] => 1
[user_image] => 2014/11/24c4a6835e667b67b82cea3666841ac7%s.jpg
[is_invisible] => 0
[user_group_id] => 6
[language_id] =>
[profile_image] => http://app.campusknot.com/theme/frontend/foxplus/style/default/image/noimage/profile.png
)
)
For achieving this desired output result I tried following code bu couldn't get the desired refined output result as I expected.
//My attempted code
$a = $result=array_diff($a,$b);
I also tried array_diff_assoc()
function but that also didn't give me the desired output result.
Can someone please guide me in this regard in order to bring the desired output result?