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

bernd wilke t3ng at bernd-wilke.net
Wed Jul 10 12:39:57 CEST 2013


Am 10.07.13 12:15, schrieb François Suter:
> Hi Markus,
>
>> I suggest to use "the middle way" and just do a trim() on the values,
>> which still does the trick without RegExp.
>
> That's what I thought too, but inList() doesn't explode the string. It
> just does:
>
> return strpos(',' . $list . ',', ',' . $item . ',') !== FALSE ? TRUE :
> FALSE;
>
> So again, exploding the string and trimming its components is much more
> work than using strpos(). I don't know what the performance impact could
> be, given that it's such a widespread method.

as exploding and imploding would be too expensive a replacement of 
(white)spaces should be possible

return strpos(',' . str_replace(' ', '', $list) . ',', ',' . $item . 
',') !== FALSE ? TRUE : FALSE;

otherwise you have to ensure that all lists written are 'de-spaced'.

bernd
-- 
http://www.pi-phi.de/cheatsheet.html


More information about the TYPO3-team-core mailing list