Sha256: 49020fd3f8c506caeae41ccbe44086ae6cb4b4877c836e3b40db3af98eaa64c9
Contents?: true
Size: 593 Bytes
Versions: 396
Compression:
Stored size: 593 Bytes
Contents
<?php function encode($string) { $a_z = range('a', 'z'); $z_a = range('z', 'a'); $string = preg_replace("/[^a-z0-9]+/", "", strtolower($string)); $len = strlen($string); $count = 0; $encoded = []; foreach (str_split($string) as $char) { $count++; if (is_numeric($char)) { $encoded[] = $char; } if (ctype_lower($char)) { $encoded[] = $z_a[array_search($char, $a_z)]; } if ($count % 5 == 0 && $count < $len) { $encoded[] = ' '; } } return implode('', $encoded); }
Version data entries
396 entries across 396 versions & 1 rubygems