-2

I need to get to the [slug] => coaching... However the array number changes and I need to access whatever the number is? I know I can use categories->terms[10]->slug for this one, but how do I access whatever the number?

[categories] => EM_Categories Object
    (
        [is_ms_global:protected] => 1
        [taxonomy:protected] => event-categories
        [meta_key:protected] => event-category
        [terms_name:protected] => categories
        [term_class:protected] => EM_Category
        [terms] => Array
            (
                [10] => EM_Category Object
                    (
                        [option_ms_global] => 1
                        [option_name] => category
                        [taxonomy] => event-categories
                        [id] => 10
                        [term_id] => 10
                        [name] => Coaching
                        [slug] => coaching
                        [term_group] => 0
                        [term_taxonomy_id] => 10
                        [description] => 
                        [parent] => 0
                        [count] => 2
                        [image_url] => 
                        [color] => 
gcooke75
  • 51
  • 1
  • 6

1 Answers1

0

I don't know which your language is, but in JS you can use find fn with a lambda expression.

In your example

TermsArray.find((x)=> x[slug] == "coaching");

Or something like that.