<?php
function stringToRandomClass($str, $max = 10) {
$hash = crc32($str);
$number = ($hash % $max) + 1;
return "random$number";
}
$content = "Hello";
$randomClass = stringToRandomClass(substr($content, 0, 4));
?>
<div class="<?= $randomClass ?>"><?= htmlspecialchars($content) ?></div>