Req #55179 [Com]: Offer preg_match with array-support for pattern

From: Date: Sun, 24 Dec 2017 08:58:17 +0000
Subject: Req #55179 [Com]: Offer preg_match with array-support for pattern
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213263@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55179&edit=1 ID: 55179 Comment by: arf2 dot njm at yahoo dot com Reported by: neufeind@php.net Summary: Offer preg_match with array-support for pattern Status: Open Type: Feature/Change Request Package: PCRE related PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: this informations are very useful for me http://www.abaengineerco.com/ http://www.aranosaze.com/ http://behtarspc.com http://designstoneco.com/ Previous Comments: ------------------------------------------------------------------------ [2011-07-11 07:38:32] neufeind@php.net Description: ------------ Maybe the existing preg_match could allow for an array to be given as $pattern. Or if not a preg_match_array() might be an alternative. Idea is to check a string against a list of pattern. First matched pattern would return. Test script: --------------- <?php $patterns = array( '/\.link1$/', '/\.link2$/', '/\.link3$/', '/\.link4$/', ); $subject = "field.link2"; if(preg_match($patterns, $subject)) { // ... } Expected result: ---------------- preg_match should find the first pattern that matches (if any). Actual result: -------------- No array-support for $pattern yet. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55179&edit=1

« previous php.bugs (#213263) next »