You are here

public static function Element::toTail in Lightning Core 8.4

Same name and namespace in other branches
  1. 8.5 src/Element.php \Drupal\lightning_core\Element::toTail()
  2. 8 src/Element.php \Drupal\lightning_core\Element::toTail()
  3. 8.2 src/Element.php \Drupal\lightning_core\Element::toTail()
  4. 8.3 src/Element.php \Drupal\lightning_core\Element::toTail()

Moves element(s) to the end of an associative array.

Parameters

array $values: The array to modify.

mixed $key: The key(s) of the element(s) to move.

1 call to Element::toTail()
ElementTest::testToTail in tests/src/Unit/ElementTest.php
@covers ::toTail

File

src/Element.php, line 61

Class

Element
Helpful functions for dealing with renderable arrays and elements.

Namespace

Drupal\lightning_core

Code

public static function toTail(array &$values, $key) {
  $key = (array) $key;
  $keys = array_keys($values);
  $keys = array_diff($keys, $key);
  $keys = array_merge($keys, $key);
  static::order($values, $keys);
}