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

Xavier Perseguers xavier at typo3.org
Wed Jul 10 13:26:13 CEST 2013


Hi,

I'm not OK with the suggestion:

$myList1 = 'Something Special, 1, 2';
$myList2 = 'SomethingSpecial, 3';

I want to search for 'SomethingSpecial', I should not get a positive
result for $myList1.

Kind regards
Xavier

Markus Klein wrote:
> I'm ok with your suggestion.
> 
> Kind regards
> Markus
> 
> ------------------------------------------------------------
> Markus Klein
> TYPO3 CMS Active Contributors Team Member
> 
>> -----Original Message-----
>> From: typo3-team-core-bounces at lists.typo3.org [mailto:typo3-team-core-
>> bounces at lists.typo3.org] On Behalf Of bernd wilke
>> Sent: Wednesday, July 10, 2013 12:40 PM
>> To: typo3-team-core at lists.typo3.org
>> Subject: Re: [TYPO3-core] GeneralUtility::inList() and spaces
>>
>> 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
>> _______________________________________________
>> Before posting to this list, please have a look to the posting rules on the
>> following websites:
>>
>> http://typo3.org/teams/core/core-mailinglist-rules/
>> http://typo3.org/development/bug-fixing/diff-and-patch/
>> _______________________________________________
>> TYPO3-team-core mailing list
>> TYPO3-team-core at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-team-core
> 

-- 
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