S
S
sham632019-01-14 23:35:33
Yii
sham63, 2019-01-14 23:35:33

Why is the foreach loop breaking?

There is a loop in the controller (yii2)

foreach ($accounts as $account) {
                 
                if($account['statys']!="3") // только активные
                { 
                    $inst = $this->InstaHash($account['url']);
                    //$inst_user = $inst['entry_data']['ProfilePage'][0]['graphql']['user'];
                    $inst_user = $inst['entry_data']['ProfilePage'][0]['graphql']['user'];
                 
                    $posts = $inst_user['edge_owner_to_timeline_media']['edges'];
                     echo 'Yes';//var_dump($posts);
                   
 
                     
                }
                
                
            }

For some reason, only one cycle in the construction ( foreach ($accounts as $account) ) goes through, although the data is coming.
If you remove the line $inst_user = $inst['entry_data']['ProfilePage'][0]['graphql']['user']; then everything works normally. I think it's all about the uppercase ProfilePage. Who reacts like this? (maybe yii2) and how to be?
Thanks in advance for your answers! :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question