多次元配列があるとしましょう。例えば:
Array (
[0] => Array (
[animal_id] => 5494
[animal_name] => "Suzy"
[animal_type] => "zebra"
[animal_location] => 0
[animal_awake] => 1
[animal_age] => 3 )
[1] => Array (
[animal_id] => 5494
[animal_name] => "Joshua"
[animal_type] => "panda"
[animal_location] => 5
[animal_awake] => 0
[animal_age] => 8 )
[2] => Array (
[animal_id] => 5494
[animal_name] => "Debra"
[animal_type] => "snake"
[animal_location] => 7
[animal_awake] => 1
[animal_age] => 3 )
[3] => Array (
[animal_id] => 5495
[animal_name] => "Caleb"
[animal_type] => "zebra"
[animal_location] => 0
[animal_awake] => 1
[animal_age] => 3 )
[4] => Array (
[animal_id] => 5495
[animal_name] => "Joshua"
[animal_type] => "panda"
[animal_location] => 5
[animal_awake] => 0
[animal_age] => 8 )
[5] => Array (
[animal_id] => 5495
[animal_name] => "Debra"
[animal_type] => "snake"
[animal_location] => 7
[animal_awake] => 1
[animal_age] => 3 )
[6] => Array (
[animal_id] => 5496
[animal_name] => "Emily"
[animal_type] => "zebra"
[animal_location] => 0
[animal_awake] => 1
[animal_age] => 3 )
[7] => Array (
[animal_id] => 5496
[animal_name] => "Joshua"
[animal_type] => "panda"
[animal_location] => 5
[animal_awake] => 0
[animal_age] => 8 )
[8] => Array (
[animal_id] => 5496
[animal_name] => "Debra"
[animal_type] => "snake"
[animal_location] => 7
[animal_awake] => 1
[animal_age] => 3 )
)
そして、私はすべてのヘビをヘビと比較し、すべてのパンダをパンダなどと比較し(パンダに対するヘビではありません)、一意の要素を配列に入れます(すべての一意の要素を単一の配列に入れます)、どうすればよいですか?これをやってみてください。それらは配列内の要素であるため、私は少し困惑しています。また、何種類あるのか事前にはわかりません。たとえば、あるときはパンダ、クマ、ヘビの多次元配列を渡すことができました。次回は鳥、猫、パンダ、ゼブラの配列を渡すことができました。
何か案は?
最終出力
Array (
[0] => Array (
[animal_id] => 5494
[animal_name] => "Suzy"
[animal_type] => "zebra"
[animal_location] => 0
[animal_awake] => 1
[animal_age] => 3 )
[1] => Array (
[animal_id] => 5494
[animal_name] => "Joshua"
[animal_type] => "panda"
[animal_location] => 5
[animal_awake] => 0
[animal_age] => 8 )
[2] => Array (
[animal_id] => 5495
[animal_name] => "Caleb"
[animal_type] => "zebra"
[animal_location] => 0
[animal_awake] => 1
[animal_age] => 3 )
[3] => Array (
[animal_id] => 5495
[animal_name] => "Debra"
[animal_type] => "snake"
[animal_location] => 7
[animal_awake] => 1
[animal_age] => 3 )
[4] => Array (
[animal_id] => 5496
[animal_name] => "Emily"
[animal_type] => "zebra"
[animal_location] => 0
[animal_awake] => 1
[animal_age] => 3 )
)