Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get value from array with stdclass object?

Tags:

php

I have get following output in codeigniter?

Array
(
    [0] => stdClass Object
        (
            [id] => 8
            [book_category] => C Program
            [book_id] => 2
            [book_name] => C Language
            [book_category_id] => 8
            [book_in_stock] => 5
        )

    [1] => stdClass Object
        (
            [id] => 8
            [book_category] => C Program
            [book_id] => 1
            [book_name] => C++
            [book_category_id] => 8
            [book_in_stock] => 10
        )

    [2] => stdClass Object
        (
            [id] => 9
            [book_category] => English
            [book_id] => 3
            [book_name] => Comp Eng
            [book_category_id] => 9
            [book_in_stock] => 5
        )

    [3] => stdClass Object
        (
            [id] => 9
            [book_category] => English
            [book_id] => 4
            [book_name] => Eng English
            [book_category_id] => 9
            [book_in_stock] => 5
        )

)

so i need get value from the above array without foreach of debugging purpose?

like image 882
Padam Shankhadev Avatar asked Jun 28 '12 08:06

Padam Shankhadev


1 Answers

Try this:

echo $array[0]->id;
echo $array[0]->book_category;
like image 137
ariefbayu Avatar answered Sep 28 '22 15:09

ariefbayu