8000 feature #13373 [String] Added the containsAny() method (javiereguiluz) · symfony/symfony-docs@4d4c4b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d4c4b5

Browse files
committed
feature #13373 [String] Added the containsAny() method (javiereguiluz)
This PR was squashed before being merged into the master branch. Discussion ---------- [String] Added the containsAny() method Fixes #13361. Commits ------- f140ba2 [String] Added the containsAny() method
2 parents 4cf2cdf + f140ba2 commit 4d4c4b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/string.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ Methods to Search and Replace
300300
u('avatar-73647.png')->match('/avatar-(\d+)\.png/');
301301
// result = ['avatar-73647.png', '73647']
302302

303+
// checks if the string contains any of the other given strings
304+
u('aeiou')->containsAny('a'); // true
305+
u('aeiou')->containsAny(['ab', 'efg']); // false
306+
u('aeiou')->containsAny(['eio', 'foo', 'z']); // true
307+
303308
// finds the position of the first occurrence of the given string
304309
// (the second argument is the position where the search starts and negative
305310
// values have the same meaning as in PHP functions)
@@ -327,6 +332,10 @@ Methods to Search and Replace
327332
return '['.$match[0].']';
328333
}); // result = '[1][2][3]'
329334

335+
.. versionadded:: 5.1
336+
337+
The ``containsAny()`` method was introduced in Symfony 5.1.
338+
330339
Methods to Join, Split, Truncate and Reverse
331340
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332341

0 commit comments

Comments
 (0)
0