I can not figure it out. I try to get everything going in this way, but it does not work.

$response_2 = file_get_contents("http://api.vk.com/method/likes.getList?type=photo&owner_id=".$owner_id."&item_id=".$item_id."&filter=likes"); $resp_2 = json_decode($response_2, true); if (in_array($pr_user, $resp_2['response']['users'])) {echo "Лайк к Фото поставлен"; }else{echo "Лайк к Фото НЕ поставлен";} 

Rather, it works, but before that it shows such an error

 Warning: in_array() [function.in-array]: Wrong datatype for second argument in Q:\home\localhost\www\vk_servike\vk_service\vklike\vklike.php on line 45 

How to be? What is the reason? Help someone.

    2 answers 2

    This is not a mistake but just a warning. It is literally written that you are passing the wrong data type to the second argument of the function.

    • And you can disable this warning if you don’t? - Anatoly
    • Probably it is necessary to listen to it and pass all the same variable that the function expects to receive. In general, warnings can be turned off, although this is not usually done during the development process. For example: stackoverflow.com/questions/1645661/… - ComBin
    • I did this if (@! In_array ($ pr_user, $ resp_2 ['response'] ['users'])) and everything works - Anatoly
    • It is also an option. :) - ComBin
    • one
      Not an option. Because it is not professional and wrong to extinguish mistakes in this way. Errors must be corrected. Even warning . At least not a dog. Because then you will expect some one behavior from the code, and another will occur. And in the code such crutches are stuck. It’s better to really see what comes in and what is given to the function and and guide in what the function really expects - Alexey Shimansky

    If you have access to the php.ini file, then we find the error_reporting parameter in it and set the value:

     error_reporting = E_ERROR 

    Also warnings can be disabled via .htaccess:

     php_value error_reporting 1 

    You can also add the following lines to index.php from the site root:

     <?php error_reporting( E_ERROR ); ?>