%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/varak.net/video.varak.net/utils/
Upload File :
Create Path :
Current File : /www/varak.net/video.varak.net/utils/Strings.php

<?php
/**
 * Created by PhpStorm.
 * User: Turbo
 * Date: 14.12.2015
 * Time: 20:11
 */

namespace Utils;

class Strings
{
	public static function truncate($text, $chars = 40)
	{
//		$text = $text . " ";
		$length = strlen($text);
		$text = substr($text, 0, $chars);
//		$text = substr($text, 0, strrpos($text, ' '));
		if (strlen($text) < $length) {
			$text = $text . "...";
		}

		return $text;
	}

	public static function removeSuffix($fileName)
	{
		return preg_replace('/\\.[^.\\s]{3,4}$/', '', $fileName);
	}

	public static function startsWith($haystack, $needle) {
		// search backwards starting from haystack length characters from the end
		return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
	}
	public static function endsWith($haystack, $needle) {
		// search forward starting from end minus needle length characters
		return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
	}

	public static function removeNonPrintable($string)
	{
		return preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $string);
	}
}

Zerion Mini Shell 1.0