R
R
rusgayfer2017-07-29 18:15:46
In contact with
rusgayfer, 2017-07-29 18:15:46

How to make an if else output if there is and is not?

It is necessary to display if the community is banned, then I display the error "Community banned", if not banned, then we do not display anything.
I do so

$group = json_decode(file_get_contents("https://api.vk.com/method/groups.getById?group_ids={$groupId}&v=5.67"),true);

if($group['response'][0]['deactivated'] == "banned"){
        $error_code = "<br><div class=\"callout callout-danger\"> Сообщество заблокировано!</div>";
        }
        else{
        $error_code = "";
        }

This only shows up on the page if the community is banned, and if not, it can't find it: How do I fix this?
$group['response'][0]['deactivated']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-07-29
@rusgayfer

if( isset( $group['response'],$group['response'][0], $group['response'][0]['deactivated'])
  &&
  $group['response'][0]['deactivated'] === "banned"
){ // ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question