Actions
Feature #53677
closedGeneralUtility::rmFromList : allow to call GeneralUtility::trimExplode
Status:
Closed
Priority:
Could have
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:
100%
Estimated time:
PHP Version:
Tags:
Complexity:
no-brainer
Sprint Focus:
Description
If a list contains space between comma and value, rmFromList doesn't unset element.
Example :- "1,2, 3,4"
- If we want to delete "3" entry, we have to pass " 3" instead of "3"
Current code is :
static public function rmFromList($element, $list) { $items = explode(',', $list); foreach ($items as $k => $v) { if ($v == $element) { unset($items[$k]); } } return implode(',', $items); }
To avoid breaking changes, it can be introduced a new argument which enable trim.
Improved code :
static public function rmFromList($element, $list, $trimElements = false) { if(!$trimElements){ $items = explode(',', $list); } else{ $items = self::trimExplode(",", $list); } foreach ($items as $k => $v) { if ($v == $element) { unset($items[$k]); } } return implode(',', $items); }
Files
Actions