def str_to_bin_array(number, array_length=None):
    """Creates a binary array for the given number. If a length is specified, then the returned array will have the same
    add leading zeros to match `array_length`.

    Args:
      number: the number to be represented as a binary array.
      array_length: optional) the length of the binary array to be created. (Default value = None)

    Returns:
      the binary array representation of `number`.

    """
    bin_str = "{0:b}".format(number)
    bin_str = bin_str.zfill(array_length) if array_length else bin_str
    return list(map(int, bin_str))