Straddling Checkerboard Cipher The Straddling Checkerboard is a method for converting letters to numbers and was part of a pencil an paper cipher known as VIC
To convert letters to numbers first you have to make a checkboard like this:
    0   1   2   3   4   5   6   7   8   9
   ---------------------------------------
    E   T       A   O   N       R   I   S
2 | B   C   D   F   G   H   J   K   L   M
6 | P   Q   #   U   V   W   X   Y   Z   .

Is a 10 x 3 table filled with 28 different simbols and two blanks on the first row.
The labels of second and third row are the position of the blanks on the first one.
To cipher a message you have to replace each letter with the column label.
If it is not on the first row, prepend row label:
G -&gt; 24
O -&gt; 4
L -&gt; 28
F -&gt; 23

The extra simbols # and . are used to escape numbers and to indicate full-stop.
Task
Input:

0 to 26 unsorted unique letters (key)
4 digits, #1 != #2 and #3 != #4
Alphanumeric message to be encoded

Output:

Digits representing the encoded message

Implementation:
The table will be filled with the 26 character recived by input. If lengh is less than 26, the remaining spaces will be filled with the missing letters in alphabetical order.
The first two integers represent the blank spaces on the first row (and labels for second and third row).Next two integers represent the position of # and . on the third row.

Example:
Input: codeglf , 4 6 8 9 , &quot;programming puzzles are gr8.&quot;
Yields this table:
   0 1 2 3 4 5 6 7 8 9
   -------------------
   c o d e   g   l f a
4| b h i j k m n p q r
6| s t u v w x y z # .

Output: 47491549945454246547727777637094935496886869

Note1: Spaces are not encoded and not included in the output.
Note2: Original message may contain letters, numbers, spaces and . (assume same capitalisation as the key)
Note3: If there is a number in the original message you have to output the corresponding code number for # followed by the number then another # code (68 in the example) and then continue with the letters.

Example2:
Input: toearly , 2 8 6 1 , &quot;wake up at 06.am&quot;
   0 1 2 3 4 5 6 7 8 9
   -------------------
   t o   e a r l y   b
2| c d f g h i j k m n
8| p . q s u v # w x z

w  a  k e  u  p a t  # 0 6  #  . a  m 
87 4 27 3 84 80 4 0 86 0 6 86 81 4 28

Output: 87427384804086068681428

This is the complete VIC cipher question.
PHP>=7.1, 226 Bytes

for([,$c,$a,$b,$d,$e,$t]=$argv,$c.=join(preg_grep("#[^$c]#",range(a,z)));$p&lt;30;)$x[in_array($y=["",$a,$b][$p/10].$p++%10,[$a,$b,$b.$d,$b.$e])?"__#."[$m++]:$c[$i++]]=$y;for(;a&amp;$w=$t[$k++];)echo is_numeric($w)?$x["#"].$w:$x[$w];


Online Version

Expanded

for([,$c,$a,$b,$d,$e,$t]=$argv #short variables in input array
,$c.=join(preg_grep("#[^$c]#",range(a,z))) # join the rest of alphabet
;$p&lt;30;) # loop 30 times
  $x[in_array($y=["",$a,$b][$p/10].$p++%10 # is actual position reserved?
  ,[$a,$b,$b.$d,$b.$e]) # reserved positions
    ?"__#."[$m++] # set reserved positions with chars underscore instead spaces to avoid encoding
    :$c[$i++]] # set alpabetic characters
  =$y; # make encoding array
for(;a&amp;$w=$t[$k++];) # loop through string which shall be encoded
  echo is_numeric($w) 
    ?$x["#"].$w # printing for digits
    :$x[$w]; #printing for the other characters