take first 8 numbers of md5 in php code example Example: php limit string length if (strlen($str) > 10) $str = substr($str, 0, 7) . '...';