Для получения полного доступа
зарегистрируйтесь.

dignityinside    26   27,912


It seems user decided to remain silent about himself.
  • php, mysql, oop, yii, zend framework, apache2, nginx, debian
  • Computer Science Expert: Software Development
  • Registered 5 years ago
Профиль завершён на 50 %
50 %

Function to sort an array according to its keys which are floats casted as strings.

function sort_string_float($a, $b) {

	$a = (float) $a;
	$b = (float) $b;

	if ($a == $b) {
		return 0;
	}

	return $a < $b ? -1 : 1;

}

// use
uksort($l1_data, 'self::sort_string_float');

Small bash script to delete redis cache.

 redis-cli KEYS "username*" | while read key; do redis-cli DEL $key; echo $key; done

Check whether value an array is not empty.

$arr = ['', 'apple', ''];

if (!empty(array_filter($arr))) {
    // do something
}

Check whether value an array is not empty.

$arr = ['', 'apple', ''];

if (implode('', array_unique($arr)) != '') {
    // do something
}

Check whether haystack ends with needle.

function ends_with($haystack, $needle) {

	if ($needle === '') {
    	return true;
	}

	return strtolower(substr($haystack, -strlen($needle))) === $needle;

}

Check whether haystack starts with needle.

function starts_with($haystack, $needle) {
	return $needle === '' || stripos($haystack, $needle) === 0;
}

Run the following command to reveal your IP address.

ifconfig eth0 | grep inet | awk '{ print $2 }'