N
N
nezzard2016-12-07 13:34:03
PHP
nezzard, 2016-12-07 13:34:03

How to compare two arrays by key?

Good afternoon, you need to compare two arrays according to the principle of the array_diff_assoc function.
The problem is that the arrays have different structures.
I need to compare two arrays by the $array->post_title key. function array_diff_assoc
Is it possible to implement this?

sample data

Первый
array (
  0 =>
  array (
    'post_title' => '5 Хвилин - Без Обмежень',
    'ID' => '0',
    'song_name' => '5 Хвилин',
    'song_artist' => 'Без Обмежень',
  ),
  1 =>
  array (
    'post_title' => 'Until The End - E-Type',
    'ID' => '0',
    'song_name' => 'Until The End',
    'song_artist' => 'E-Type',
  ),
  2 =>
  array (
    'post_title' => 'Send My Love(To Your New Lover) - Adele',
    'ID' => '0',
    'song_name' => 'Send My Love(To Your New Lover)',
    'song_artist' => 'Adele',
  ),
  3 =>
  array (
    'post_title' => 'I Do - Lisa Loeb',
    'ID' => '0',
    'song_name' => 'I Do',
    'song_artist' => 'Lisa Loeb',
  ),
  4 =>
  array (
    'post_title' => 'Північна (Northern Dance) - Руслана',
    'ID' => '0',
    'song_name' => 'Північна (Northern Dance)',
    'song_artist' => 'Руслана',
  ),
  5 =>
  array (
    'post_title' => 'Hey Baby - Dj Otzi',
    'ID' => '0',
    'song_name' => 'Hey Baby',
    'song_artist' => 'Dj Otzi',
  ),
  6 =>
  array (
    'post_title' => 'Твои Глаза - Loboda',
    'ID' => '0',
    'song_name' => 'Твои Глаза',
    'song_artist' => 'Loboda',
  ),
  7 =>
  array (
    'post_title' => 'Так, Як Ти - Red Sofa',
    'ID' => '0',
    'song_name' => 'Так, Як Ти',
    'song_artist' => 'Red Sofa',
  ),
  8 =>
  array (
    'post_title' => 'A Little Bit Of Sunshine - Reamonn',
    'ID' => '0',
    'song_name' => 'A Little Bit Of Sunshine',
    'song_artist' => 'Reamonn',
  ),
)

Второй
array (
  0 =>
  array (
    'post_title' => '5 Хвилин - Без Обмежень',
    'ID' => '565',
  ),
  1 =>
  array (
    'post_title' => 'Until The End - E-Type',
    'ID' => '567',
  ),
  2 =>
  array (
    'post_title' => 'Send My Love(To Your New Lover) - Adele',
    'ID' => '569',
  ),
  3 =>
  array (
    'post_title' => 'I Do - Lisa Loeb',
    'ID' => '571',
  ),
  4 =>
  array (
    'post_title' => 'Північна (Northern Dance) - Руслана',
    'ID' => '573',
  ),
  5 =>
  array (
    'post_title' => 'Твои Глаза - Loboda',
    'ID' => '576',
  ),
  6 =>
  array (
    'post_title' => 'Так, Як Ти - Red Sofa',
    'ID' => '577',
  ),
  7 =>
  array (
    'post_title' => 'A Little Bit Of Sunshine - Reamonn',
    'ID' => '578',
  ),

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-12-07
@nezzard

What's the problem? ideone.com/1h5TRl
you'd better give examples of arrays. better too on ideone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question