code: private function getPermissionsArrayKeyForId(array $permissionsArray, int $id): ?int 
      {
          foreach ($permissionsArray as $key => $permission) {
              if ($permission['id'] == $id) {
                  return $key;
              }
          }
  
          return null;
      }
docs: note, careful when checking return value as 0 can be returned (evaluates to false)