모든 연락처가있는 배열이 있고 모든 그룹이있는 배열이 있습니다. 연락처 배열 http://www.google.com/m8/feeds/groups/j**/base/3166d58a8c**25
의 그룹 이름 YouTube
으로 어떻게 바꿀 수 있습니까? Google Contacts API v3는 그룹 이름을 ID로 저장하므로이 ID를 그룹 이름으로 바꾸고 싶습니다.
예
어레이 그룹 :
array(2) {
[0]=>
array(3) {
["value"]=>
string(87) "http://www.google.com/m8/feeds/groups/**/base/***b87ad92"
["name"]=>
string(4) "Family"
["label"]=>
string(4) "Family"
}
[1]=>
array(3) {
["value"]=>
string(87) "http://www.google.com/m8/feeds/groups/j**/base/3166d58a8c**25"
["name"]=>
string(7) "YouTube"
["label"]=>
string(7) "YouTube"
}
}
어레이 연락처 :
array(250) {
[0]=>
array(8) {
["value"]=>
string(15) "X Y"
["name"]=>
string(15) "X Y"
["email"]=>
string(25) "[email protected]"
["phone"]=>
string(10) "044564"
["group"]=>
string(87) "http://www.google.com/m8/feeds/groups/j**/base/3166d58a8c**25"
["phonework"]=>
string(10) "0479//804"
["address"]=>
string(28) "55222 City"
["label"]=>
string(15) "Bla"
}
......
}
최종 출력은 다음과 같습니다.
array(250) {
[0]=>
array(8) {
["value"]=>
string(15) "X Y"
["name"]=>
string(15) "X Y"
["email"]=>
string(25) "[email protected]"
["phone"]=>
string(10) "044564"
["group"]=>
string(87) "YouTube"
["phonework"]=>
string(10) "0479//804"
["address"]=>
string(28) "55222 City"
["label"]=>
string(15) "Bla"
}
......
}
중첩 루프를 만드십시오. 먼저 연락처를 루프 (덮어 쓰기) 한 다음 그 안에 그룹을 포함합니다. 내부 루프 내에서 평등 비교를 수행하십시오.
foreach($contacts as &$contact) {
// ^ reference
foreach($groups as $group) {
if($contact['group'] == $group['value']) {
$contact['group'] = $group['name'];
}
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다