title: PHP-Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given
body: <p>Locally trying to decrypt a binary file with the given ciper. The data separated with 0A in hexadecimal. In the decrypting phase my array works like an int, and I do not know why. Is there a proper solution to it?</p>
  <ul>
  <li><p>php version:8.0.11</p>
  </li>
  <li><p>tried to reinstall xampp</p>
  </li>
  <li><p>tried castings</p>
  <pre><code> &lt;?php
           if(count($_POST)&gt;0)
           {
  
               $ciper = array(5, -14, 31, -9, 3);
  
               $dec_arr = [];
               $ind = 0;
               $handle = fopen(&quot;secret.txt&quot;, &quot;r&quot;);
               if ($handle) {
                   while (!feof($handle)) {
                       $hex = bin2hex(fread ($handle , 1 ));
                       $dec_arr[$ind] = hexdec($hex);
                       $ind++;
                   }
                   fclose($handle);
               }
               unset($dec_arr[(count($dec_arr)-1)]);                   
  
               $raw_data = &quot;&quot;;
               for($i = 0, $k = 0; $i &lt; count($dec_arr); $i++)//Warning: Trying to access array offset on value of type int
               {                           
                   if($dec_arr[$i]==10)
                   {
                       $dec_arr[$i] = 59;
                       $k = 0;
                   }
                   else
                   {
                       $dec_arr = ((($dec_arr[$i] + 256) - $ciper[$k])%256);//Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given
                   }
                   $raw_data .= chr($dec_arr[$i]);
                   $k = (($k+1)%5);                    
               }
           }?&gt;
  </code></pre>
  </li>
  </ul>