Ó ìåíÿ åñòü äâà ìàññèâà îäèí èñïîëüçóåòñÿ êàê ñïèñîê ññûëàþùèéñÿ íà äðóãîé ìàññèâ. Êàê íàéòè ïîõîæèå ýëåìåíòû âî âòîðîì ìàññèâå è çàìåíèòü èõ. Íàïðèìåð â îáîèõ ìàññèâàõ åñòü òàêîé ïàðàìåòð êàê author1, author2… author7. Â ïåðâîì òàêæå ïðèñóòñòâóåò id, ïîñëå ñðàâíåíèÿ è çàìåíû âìåñòî author, âî âòîðîì äîëæåí íàõîäèòñÿ id àâòîðà, ïåðâîãî ìàññèâà.
Ïðèâåäó ïðèìåð, ìàññèâà:
Ïåðâûé:
Êàê ýòî ìîæíî ñäåëàòü? Âîò ñàìè ìàññèâû
$arr1 = array(array('id'=>11,'name'=>'author1'),
array('id'=>31,'name'=>'author2'),
array('id'=>43,'name'=>'author3'),
array('id'=>73,'name'=>'author4'),
array('id'=>89,'name'=>'author5'),
array('id'=>21,'name'=>'author6'),
array('id'=>32,'name'=>'author7'));
$arr2 = array(array('author1','book1','year1','year2'),
array('author1','book2','year1','year2'),
array('author1','book3','year1','year2'),
array('author2','book1','year1','year2'),
array('author2','book2','year1','year2'),
array('author2','book3','year1','year2'),
array('author3','book1','year1','year2'),
array('author3','book2','year1','year2'),
array('author3','book3','year1','year2'),
array('author3','book4','year1','year2'),
array('author3','book5','year1','year2'),
array('author3','book6','year1','year2'),
array('author3','book7','year1','year2'),
array('author4','book1','year1','year2'),
array('author4','book2','year1','year2'),
array('author4','book3','year1','year2'),
array('author5','book1','year1','year2'),
array('author5','book2','year1','year2'),
array('author6','book1','year1','year2'),
array('author7','book1','year1','year2'),
array('author7','book2','year1','year2'));