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

JoH asenau info at cybercraft.de
Tue Jul 16 11:53:58 CEST 2013

>>> Since we just have to check, if a string is there at all, without
>>> caring about the other strings and the position within the list,
>>> explode should be the way to go, according to these benchmarks:
>>> http://www.werbe-markt.de/php-optimierung-strings-durchsuchen-vor-
>> zerl
>>> egen.php
>> Just forgot to mention:
>> But of course in this case, the delimiter has to be the comma + string +
>> comma and not just a comma ...
> 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));
	isset($array[$item]) ||
	isset($array[' ' . $item]) ||
	isset($array[$item . ' ']) ||
	isset($array[' ' . $item . ' '])
) {
	return TRUE;
} else {
	return FALSE;



Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com

More information about the TYPO3-team-core mailing list