[TYPO3-core] GeneralUtility::inList() and spaces

Xavier Perseguers xavier at typo3.org
Tue Jul 16 12:00:19 CEST 2013


Hi JoH,

>> Which does not help us here, since we want to compensate for
>> whitespaces around commas.
> 
> Still doing it with array functions should be the faster approach,
> especially with longer CSV lists.
> 
> $array = array_flip(explode(',', $list));
> if(
>     isset($array[$item]) ||
>     isset($array[' ' . $item]) ||
>     isset($array[$item . ' ']) ||
>     isset($array[' ' . $item . ' '])
> ) {
>     return TRUE;
> } else {
>     return FALSE;
> }

What about *two* spaces? ;-)

-- 
Xavier Perseguers
Release Manager TYPO3 4.6

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org



More information about the TYPO3-team-core mailing list