/** * Extract the last `$num` characters from a string. * * @param string $str * the string to extract the characters from. * @param integer $num * the number of characters to extract. * @return string|boolean * a string containing the last `$num` characters of the * input string, or false on failure. */ public static function right($str, $num){ $str = substr($str, strlen($str)-$num, $num); return $str; } /** * Extract the first `$num` characters from a string. * * @param string $str * the string to extract the characters from. * @param integer $num * the number of characters to extract. * @return string|boolean * a string containing the last `$num` characters of the * input string, or false on failure. */ public static function left($str, $num){ $str = substr($str, 0, $num); return $str; }