|
Функция делит массив на две части или возвращает части масива до и после определённого ключа |
Обновлённый PHP-Fusion Bogatyr / Free CMS PHP-Fusion 7 Bogatyr / PHP-function for arrays / Функция делит массив на две части или возвращает части масива до и после определённого ключа
Russian
Function two_array_slice() делит массив на две части.
Function before_after_array_slice() возвращает части масива до и после определённого ключа |
Function Splits the array into two parts or returns the parts of the array before and after the specified key |
Обновлённый PHP-Fusion Bogatyr / Free CMS PHP-Fusion 7 Bogatyr / PHP-function for arrays / Function Splits the array into two parts or returns the parts of the array before and after the specified key
English
Function two_array_slice() Splits the array into two parts.
Function before_after_array_slice() returns the parts of the array before and after the specified key |
|
PHP |
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39
PHP
<?php
// http://php.net/manual/ru/function.array-slice.php
// array_slice() возвращает последовательность элементов массива array, определённую параметрами offset и length.
-
// RU: делит массив на две части.
// EN: Splits the array into two parts.
function two_array_slice ( $arr = array("a", "b", "c", "d", "e", "f"), $exp=2 ){
$before = array_slice($arr, 0, $exp );
$after = array_slice($arr, $exp);
return array($before, $after);
}
$two_array_slice = two_array_slice( array("a", "b", "c", "d", "e", "f"), 2 );
$before = $two_array_slice['0'];
$after = $two_array_slice['1'];
echo "<p>two_array_slice: before=". implode("|", $before). " after=". implode("|", $after). " </p>\n"; // before=a|b after=c|d|e|f
-
-
// RU: возвращает части масива до и после определённого ключа
// EN: returns the parts of the array before and after the specified key
function before_after_array_slice ( $arr = array("a", "b", "c", "d", "e", "f"), $exp=2 ){
$before = array_slice($arr, 0, $exp );
$after = array_slice($arr, ($exp+1));
return array($before, $after);
}
$two_array_slice = before_after_array_slice( array("a", "b", "c", "d", "e", "f"), 2 );
$before = $two_array_slice['0'];
$after = $two_array_slice['1'];
echo "<p>before_after_array_slice: before=". implode("|", $before). " after=". implode("|", $after). " </p>\n"; // before_after_array_slice: before=a|b after=d|e|f
-
?>
|
Добавить комментарий |
Добавить комментарий Пожалуйста, залогиньтесь для добавления комментария.
|
HTML-code and BB-code for blogs and forums |
<a href="https://php-fusion.vveb.ws/php-fusion.php?id=51">Функция делит массив на две части или возвращает части масива до и после определённого ключа</a>
[url=https://php-fusion.vveb.ws/php-fusion.php?id=51]Функция делит массив на две части или возвращает части масива до и после определённого ключа[/url]
|
|