पीएचपी ट्यूटोरियल

पीएचपी होम पीएचपी परिचय पीएचपी इंस्टाल पीएचपी सिंटैक्स पीएचपी टिप्पणियाँ पीएचपी चर पीएचपी इको / प्रिंट पीएचपी डेटा प्रकार पीएचपी स्ट्रिंग्स पीएचपी नंबर पीएचपी गणित पीएचपी स्थिरांक पीएचपी ऑपरेटर्स पीएचपी अगर ... और ... Elseif पीएचपी स्विच पीएचपी लूप्स पीएचपी कार्य पीएचपी सरणियाँ पीएचपी सुपरग्लोबल्स पीएचपी रेगेक्स

पीएचपी फॉर्म

PHP फॉर्म हैंडलिंग PHP फॉर्म सत्यापन पीएचपी फॉर्म की आवश्यकता पीएचपी फॉर्म यूआरएल/ई-मेल PHP फॉर्म पूर्ण

पीएचपी उन्नत

पीएचपी दिनांक और समय पीएचपी शामिल करें पीएचपी फाइल हैंडलिंग PHP फ़ाइल खोलें/पढ़ें PHP फ़ाइल बनाएँ/लिखें पीएचपी फ़ाइल अपलोड पीएचपी कुकीज़ पीएचपी सत्र पीएचपी फिल्टर पीएचपी फिल्टर उन्नत PHP कॉलबैक फ़ंक्शंस पीएचपी JSON पीएचपी अपवाद

पीएचपी ओओपी

पीएचपी ओओपी क्या है पीएचपी क्लासेस/ऑब्जेक्ट्स पीएचपी कंस्ट्रक्टर पीएचपी विनाशक पीएचपी एक्सेस संशोधक पीएचपी विरासत पीएचपी स्थिरांक पीएचपी सार वर्ग पीएचपी इंटरफेस पीएचपी लक्षण PHP स्टेटिक तरीके पीएचपी स्टेटिक गुण पीएचपी नेमस्पेस पीएचपी Iterables

MySQL डेटाबेस

MySQL डेटाबेस MySQL कनेक्ट MySQL डीबी बनाएँ MySQL तालिका बनाएँ MySQL डेटा डालें MySQL अंतिम आईडी प्राप्त करें MySQL एकाधिक सम्मिलित करें MySQL तैयार MySQL डेटा का चयन करें MySQL कहाँ MySQL ऑर्डर बाय MySQL डेटा हटाएं MySQL अद्यतन डेटा MySQL सीमा डेटा

पीएचपी एक्सएमएल

पीएचपी एक्सएमएल पार्सर्स पीएचपी सिंपलएक्सएमएल पार्सर पीएचपी सिंपलएक्सएमएल - प्राप्त करें पीएचपी एक्सएमएल एक्सपैट पीएचपी एक्सएमएल डोम

पीएचपी - AJAX

AJAX परिचय अजाक्स पीएचपी AJAX डेटाबेस अजाक्स एक्सएमएल AJAX लाइव खोज AJAX पोल

पीएचपी उदाहरण

पीएचपी उदाहरण पीएचपी संकलक पीएचपी प्रश्नोत्तरी पीएचपी व्यायाम पीएचपी प्रमाणपत्र

पीएचपी संदर्भ

पीएचपी सिंहावलोकन पीएचपी सरणी पीएचपी कैलेंडर पीएचपी तिथि पीएचपी निर्देशिका पीएचपी त्रुटि पीएचपी अपवाद पीएचपी फाइल सिस्टम पीएचपी फ़िल्टर पीएचपी एफ़टीपी पीएचपी JSON पीएचपी कीवर्ड पीएचपी लिबक्सएमएल पीएचपी मेल पीएचपी गणित पीएचपी विविध पीएचपी MySQLi पीएचपी नेटवर्क पीएचपी आउटपुट नियंत्रण पीएचपी रेगेक्स पीएचपी सिंपलएक्सएमएल पीएचपी स्ट्रीम पीएचपी स्ट्रिंग पीएचपी वैरिएबल हैंडलिंग पीएचपी एक्सएमएल पार्सर पीएचपी ज़िप पीएचपी समयक्षेत्र

पीएचपी preg_match_all () समारोह

❮ PHP RegExp संदर्भ

उदाहरण

एक स्ट्रिंग में "ऐन" की सभी घटनाओं का पता लगाएं:

<?php
$str = "The rain in SPAIN falls mainly on the plains.";
$pattern = "/ain/i";
if(preg_match_all($pattern, $str, $matches)) {
  print_r($matches);
}
?>

परिभाषा और उपयोग

preg_match_all()फ़ंक्शन एक स्ट्रिंग में पाए गए पैटर्न के मैचों की संख्या देता है और पाए गए मैचों के साथ एक चर को पॉप्युलेट करता है


वाक्य - विन्यास

preg_match_all(pattern, input, matches, flags, offset)

पैरामीटर मान

Parameter Description
pattern Required. Contains a regular expression indicating what to search for
input Required. The string in which the search will be performed
matches Optional. The variable used in this parameter will be populated with an array containing all of the matches that were found
flags Optional. A set of options that change how the matches array is structured.

One of the following structures may be selected:
  • PREG_PATTERN_ORDER - Default. Each element in the matches array is an array of matches from the same grouping in the regular expression, with index 0 corresponding to matches of the whole expression and the remaining indices for subpattern matches.
  • PREG_SET_ORDER - Each element in the matches array contains matches of all groupings for one of the found matches in the string.
Any number of the following options may be applied:
  • PREG_OFFSET_CAPTURE - When this option is enabled, each match, instead of being a string, will be an array where the first element is a substring containing the match and the second element is the position of the first character of the substring in the input.
  • PREG_UNMATCHED_AS_NULL - When this option is enabled, unmatched subpatterns will be returned as NULL instead of as an empty string.
offset Optional. Defaults to 0. Indicates how far into the string to begin searching. The preg_match() function will not find matches that occur before the position given in this parameter

टेक्निकल डिटेल

प्रतिलाभ की मात्रा: यदि कोई त्रुटि हुई तो पाए गए या गलत होने वाले मैचों की संख्या लौटाता है
पीएचपी संस्करण: 4+
चेंजलॉग: PHP 7.2 - PREG_UNMATCHED_AS_NULL ध्वज

PHP 5.4 जोड़ा गया - मिलान पैरामीटर वैकल्पिक हो गया

PHP 5.3.6 - ऑफ़सेट इनपुट की लंबाई से अधिक लंबा होने पर फ़ंक्शन झूठा लौटाता है

PHP 5.2.2 - नामित उप-पैटर्न (?'name') का उपयोग कर सकते हैं ) और (? <name>) सिंटैक्स पिछले (?P<name>) के अलावा

और ज्यादा उदाहरण

उदाहरण

मिलान सरणी की संरचना सेट करने के लिए PREG_PATTERN_ORDER का उपयोग करें । इस उदाहरण में, मिलान सरणी के प्रत्येक तत्व में रेगुलर एक्सप्रेशन के समूहों में से किसी एक के लिए सभी मिलान होते हैं।

<?php
$str = "abc ABC";
$pattern = "/((a)b)(c)/i";
if(preg_match_all($pattern, $str, $matches, PREG_PATTERN_ORDER)) {
  print_r($matches);
}
?>

❮ PHP RegExp संदर्भ