第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何檢查數(shù)組對象值是否也存在于另一個對象數(shù)組值中?

如何檢查數(shù)組對象值是否也存在于另一個對象數(shù)組值中?

PHP
守著星空守著你 2023-04-15 14:16:29
如何檢查一個給定數(shù)組中任何對象的鍵值是否與另一個數(shù)組中任何對象的鍵值匹配?有兩個數(shù)組,$personorg_terms和$org_terms_in_latest_post。name我想檢查一個中的值是否存在于name另一個中。如果是這樣,我們應(yīng)該返回那個name。在下面的示例中,“S4 Capital”是一個匹配項,應(yīng)該返回。$personorg_terms包含:Array(    [0] => WP_Term Object        (            [term_id] => 7436            [name] => WPP            [slug] => wpp            [term_group] => 0            [term_taxonomy_id] => 7436            [taxonomy] => company            [description] => WPP plc is a British multinational advertising and public relations company with its main management office in London, England, and its executive office in Dublin, Ireland.            [parent] => 0            [count] => 81            [filter] => raw            [term_order] => 0        )    [1] => WP_Term Object        (            [term_id] => 11814            [name] => S4 Capital            [slug] => s4-capital            [term_group] => 0            [term_taxonomy_id] => 11814            [taxonomy] => company            [description] => S4Capital is building a purely digital advertising and marketing services business for global, multi- national, regional, local and millennial-driven influencer brands.            [parent] => 0            [count] => 6            [filter] => raw            [term_order] => 0        ))$org_terms_in_latest_post包含:Array(    [0] => WP_Term Object        (            [term_id] => 11814            [name] => S4 Capital            [slug] => s4-capital            [term_group] => 0            [term_taxonomy_id] => 11814            [taxonomy] => company            [description] => S4Capital is building a purely digital advertising and marketing services business for global, multi- national, regional, local and millennial-driven influencer brands.            [parent] => 0            [count] => 6            [filter] => raw            [term_order] => 0        ))
查看完整描述

1 回答

?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗 獲得超12個贊

通過傳遞你的兩個對象數(shù)組 $personorg_terms 和 $org_terms_in_latest_post 來試試這個


function getDuplicateObject($object_arr, $other_object_arr)

{

    $duplicates = array(); 

    foreach($object_arr as $ob1){


        foreach($other_object_arr as $ob2){

            if($ob1->name == $ob2->name)

                array_push($duplicates, $ob1->name); 

        }


    }

    return $duplicates;

}


查看完整回答
反對 回復(fù) 2023-04-15
  • 1 回答
  • 0 關(guān)注
  • 168 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號