I’m really new to PHP i’ve been studying for like 2-3 days, i manage to do a few things with the API such as get the status,followers,etc, but i can’t make work showing the offline/online, shows offline even if one of them it’s online.
You are double json_decoding, the second call is unneeded
The second call to json_decode you are decoding '$twitch_api' this decodes the string $twitch_api and fails, you need json_decode($twitch_api)
You should use curl instead of file_get_contents, file_get_contents is a security reason for HTTP calls, further more there is no way to check the HTTP Status code of the response.
When using curl check the HTTP Response is a 200
if ($twitch_api->stream == null) will suffice for your online/offline check
Avoid what you are trying to do (start processing a object then start processing the same data as an array you can iterate on the object only)