How to get array element?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brett

    How to get array element?

    get_the_categor y() returns an array that looks like this:

    ResourceArray ( [0] =stdClass Object ( [cat_ID] =3 [cat_name] =>
    Certifications [category_nicena me] =ms-certifications
    [category_descri ption] =Certification Resource [category_parent] =0
    [category_count] =5 [fullpath] =/ms-certifications ) )

    I want to get the value in "category_descr iption" and have tried:

    $category = get_the_categor y();
    $cat_d = $category->category_descr iption;
    print_r($cat_d) ;

    But that doesn't print anything. What is the correct way to get the
    value I'm after?

    Thanks,
    Brett

  • josh.23.french

    #2
    Re: How to get array element?

    try

    $category = get_the_categor y();
    $category=categ ory[0];
    $cat_d = $category->category_descr iption;
    print_r($cat_d) ;

    Comment

    • josh.23.french

      #3
      Re: How to get array element?

      try

      $category = get_the_categor y();
      $category=$cate gory[0];
      $cat_d = $category->category_descr iption;
      print_r($cat_d) ;

      Comment

      • brett

        #4
        Re: How to get array element?

        try
        >
        $category = get_the_categor y();
        $category=$cate gory[0];
        $cat_d = $category->category_descr iption;
        print_r($cat_d) ;
        Yes - you are right. I went with this:

        print_r($catego ry[0]->category_descr iption);

        Thanks,
        Brett

        Comment

        Working...