Review main Merged

26481[TASK] Use arrays in str_replace() calls

Michiel Roos CR +2 V +2 Hard +415 −159 updated 01/08/14, 12:47

Commit message

Multiple consecutive calls to str_replace can be replaced with a single
call if the subject is the same.

This will speed up the replacement and in some cases has the benefit of
being able to return or use the result of the str_replace directly without
creating an intermediate variable.

Bad:
$lala = 'something';
$lala = str_replace('so', 'the', $lala);
$lala = str_replace('me', ' ', $lala);
$lala = str_replace('thing', 'other', $lala);

Good:
$lala = str_replace(
  array('so', 'me', 'thing'),
  array('the', ' ', 'other'),
  'something'
);

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 27

Show 7 more files