You are here

function simplenews_statistics_encoder_encode in Simplenews Statistics 7

Same name and namespace in other branches
  1. 7.2 simplenews_statistics_encoder/encoder.inc \simplenews_statistics_encoder_encode()
1 call to simplenews_statistics_encoder_encode()
simplenews_statistics_encoder_simplenews_statistics_encode in simplenews_statistics_encoder/simplenews_statistics_encoder.module
Implements hook_simplenews_statistics_encode().

File

simplenews_statistics_encoder/encoder.inc, line 62
Encoder for IDs. Some logic borrowed from shorturl module.

Code

function simplenews_statistics_encoder_encode($input) {
  $mapping = simplenews_statistics_encoder_base_encode_mapping();
  $var = simplenews_statistics_encoder_base_encode($input, sizeof($mapping));
  $arr = explode('-', $var);
  if (empty($arr)) {
    return $mapping[0];
  }
  if (!is_array($arr)) {
    $arr = array(
      $arr,
    );
  }
  $new_num = "";
  foreach ($arr as $pos) {
    $new_num .= $mapping[(int) trim($pos)];
  }
  return $new_num;
}