Самый быстрый способ поиска и сравнения через этот php ассоциативный массив объектов - PullRequest
0 голосов
/ 29 ноября 2018
(array) Array
(
    [0] => WP_Term Object
        (
            [term_id] => 1474
            [name] => Bij
            [slug] => bij
            [term_group] => 0
            [term_taxonomy_id] => 1474
            [taxonomy] => brand_name
            [description] => 
            [parent] => 0
            [count] => 14
            [filter] => raw
            [term_order] => 0
        )

    [1] => WP_Term Object
        (
            [term_id] => 1109
            [name] => Cal
            [slug] => cal
            [term_group] => 0
            [term_taxonomy_id] => 1109
            [taxonomy] => brand_name
            [description] => 
            [parent] => 0
            [count] => 16
            [filter] => raw
            [term_order] => 0
        )

    [2] => WP_Term Object
        (
            [term_id] => 1166
            [name] =>Glue-
            [slug] => clear-glue
            [term_group] => 0
            [term_taxonomy_id] => 1166
            [taxonomy] => brand_name
            [description] => 
            [parent] => 0
            [count] => 3
            [filter] => raw
            [term_order] => 0
        )

У меня есть поисковый запрос ($ brand_query), который я сравниваю с слагом и именем вышеупомянутого массива ($ brand_names):

 for($i=0; $i<sizeof($brand_names); $i++){
            if($brand_query==$brand_names[$i]->name||$brand_query1==$brand_names[$i]->slug){//if search matches with the name or slug do something

            }

        } 

Может использовать array_search или любой другойВстроенные функции увеличивают скорость поиска и сравнения?

...