public static function YamlFormArrayHelper::removePrefix in YAML Form 8
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.
4 calls to YamlFormArrayHelper::removePrefix()
- YamlFormElementBase::buildConfigurationForm in src/
YamlFormElementBase.php - Form constructor.
- YamlFormElementBase::getConfigurationFormProperties in src/
YamlFormElementBase.php - Get an associative array of element properties from configuration form.
- YamlFormElementHelper::isIgnoredProperty in src/
Utility/ YamlFormElementHelper.php - Determine if an element's property should be ignored.
- YamlFormEntitySettingsForm::form in src/
YamlFormEntitySettingsForm.php - Gets the actual form array to be built.
File
- src/
Utility/ YamlFormArrayHelper.php, line 205
Class
- YamlFormArrayHelper
- Provides helper to operate on arrays.
Namespace
Drupal\yamlform\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;
}