public static function WebformArrayHelper::removePrefix in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformArrayHelper.php \Drupal\webform\Utility\WebformArrayHelper::removePrefix()
Remove prefix from all top level keys in an associative array.
Parameters
array $array: An associative array.
string $prefix: Prefix to be remove from to all keys.
Return value
array An associative array with prefix removed from all top level keys.
7 calls to WebformArrayHelper::removePrefix()
- WebformArrayHelperTest::testPrefixing in tests/
src/ Unit/ Utility/ WebformArrayHelperTest.php - Tests prefix an associative array.
- WebformElementBase::buildConfigurationForm in src/
Plugin/ WebformElementBase.php - Form constructor.
- WebformElementBase::getConfigurationFormProperties in src/
Plugin/ WebformElementBase.php - Get an associative array of element properties from configuration webform.
- WebformElementComposite::valueCallback in src/
Element/ WebformElementComposite.php - Determines how user input is mapped to an element's #value property.
- WebformElementHelper::isIgnoredProperty in src/
Utility/ WebformElementHelper.php - Determine if an element's property should be ignored.
File
- src/
Utility/ WebformArrayHelper.php, line 205
Class
- WebformArrayHelper
- Provides helper to operate on arrays.
Namespace
Drupal\webform\UtilityCode
public static function removePrefix(array $array, $prefix = '#') {
$unprefixed_array = [];
foreach ($array as $key => $value) {
if ($key[0] === $prefix) {
$key = preg_replace('/^' . $prefix . '/', '', $key);
}
$unprefixed_array[$key] = $value;
}
return $unprefixed_array;
}