I needed a unique internal int to use, which would represent several random types of content that I could not hard code as class constants or configuration parameters. However, I did not want to refer to "2" when I could use the lighter sequence of the term "post". So, despite the way to get the INT value from a string that seems to work quite freely for a couple of elements.
Is there a way to do this in php and not in what I built?
$strings = array('post', 'comment', 'blog', 'article', 'forum', 'news', 'page');
foreach( $strings as $string ) {
print $string . ' = ';
$string = str_split($string);
$sum = 0;
foreach( $string as $char ) {
$sum += ord($char);
}
var_dump( $sum );
print '<br />';
}
This has nothing to do with user input, so don't worry about obvious design flaws.
: EDIT:
. "" "" "". , , 1-8 , . ( , ).
, 8 , , . , , , , , .