public static function WebformArrayHelper::insertAfter in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformArrayHelper.php \Drupal\webform\Utility\WebformArrayHelper::insertAfter()
Inserts a new key/value after the key in the array.
Parameters
array &$array: An array to insert in to.
string $target_key: The key to insert after.
string $new_key: The key to insert.
mixed $new_value: An value to insert.
2 calls to WebformArrayHelper::insertAfter()
- webform_update_8096 in includes/
webform.install.update.inc - Issue #2931888: Add a boolean flag 'use as likert' for options list and remove the machine name pattern matching in likert element.
- webform_update_8209 in includes/
webform.install.update.inc - Issue #3174132: Add (admin) notes to handlers.
File
- src/
Utility/ WebformArrayHelper.php, line 370
Class
- WebformArrayHelper
- Provides helper to operate on arrays.
Namespace
Drupal\webform\UtilityCode
public static function insertAfter(array &$array, $target_key, $new_key, $new_value) {
$new = [];
foreach ($array as $key => $value) {
$new[$key] = $value;
if ($key === $target_key) {
$new[$new_key] = $new_value;
}
}
$array = $new;
}