Last active
July 20, 2017 13:57
-
-
Save szilardhuber/7fd2bc96fd45619d139bf1fd98ef9589 to your computer and use it in GitHub Desktop.
Php 5 numbers from text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The code from Internet | |
* | |
* @package PhpFiddle | |
* @link http://phpfiddle.org | |
* @since 2012 | |
**/ | |
function magicNumber($szoveg) { | |
$result = [1, 1, 1, 1, 1]; | |
$chars = str_split($szoveg, 1); | |
for ($i = 0; $i < count($chars); $i++) { | |
$current = $result[$i % 5]; | |
$current += ord($chars[$i]); | |
$current = $current % 99; | |
$result[$i % 5] = $current; | |
} | |
return $result; | |
} | |
// Usage | |
$szoveg = "Bésla lement a boltba"; | |
// $szoveg = "cic"; | |
$result = magicNumber($szoveg); | |
echo implode(" ", $result); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment