Welcome Guest, Not a member yet? Register   Sign In
How to get value from array? message: "Cannot use object of type stdClass as array"
#1

(This post was last modified: 10-03-2018, 11:12 AM by DELE.)

How to get value [id] from array [0].


Code:
$a = ($details->production_companies);

print_r($a);
// result from print_r($a)
Array (
    [0] => stdClass Object (
        [id] => 420
        [logo_path] => /hUzeosd33nzE5MCNsZxCGEKTXaQ.png
        [name] => Marvel Studios
        [origin_country] => US )
    [1] => stdClass Object (
        [id] => 2
        [logo_path] => /4MbjW4f9bu6LvlDmyIvfyuT3boj.png
        [name] => Walt Disney Pictures
        [origin_country] => US )
)


echo $a[0]['id'];
// if i use this code results message: (Cannot use object of type stdClass as array)
[SOLVED]
Reply


Messages In This Thread
How to get value from array? message: "Cannot use object of type stdClass as array" - by DELE - 10-02-2018, 02:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB