- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
/**
* Creates a temporary file in system folder.
* @param string $prefix Prefix of filename.
* @return string Path to temp file.
*/
function temp_file($prefix = 'tmp')
{
return tempnam(sys_get_temp_dir(), $prefix);
}
/**
* Converts a two-dimensional matrix into array.
* For example, this code
* $matrix = [[1, 2],
* [3, 4]];
* matrix_array($matrix);
* Produces following result
* [1, 2, 3, 4]
* @param array $array Matrix to flat
* @return array Array
*/
function matrix_array(array $matrix)
{
$result = array();
$rows = count($matrix);
for ($i = 0; $i < $rows; $i++)
{
$result = array_merge($result, $matrix[$i]);
}
return $result;
}
/**
* Loads shared library.
*/
function load_lib($n, $f = null) {
return extension_loaded($n) or dl(((PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '') . ($f ? $f : $n) . '.' . PHP_SHLIB_SUFFIX);
}
Лучшие функции. Особенно первая.
Комментарии (0) RSS
Добавить комментарий