Tạo một PCRE để phù hợp với một tên miền hợp lệ đáng kể là phức tạp, và có một nguy hiểm nó có thể được thực hiện trở nên lỗi thời bởi sự chấp thuận của tên miền cấp cao mới. May mắn thay, bạn không phải lúc nào cũng cần để tạo ra các biểu thức thường xuyên của bạn, | Simpo PDF Merge and Split Unregistered Version - http PHP OBJECT-ORIENTED SOLUTIONS The Regexiterator is stored as match so a second foreach loop the inner loop iterates through match which contains only those titles with the string PHP. However the outer loop goes through only one book at a time so the code in the inner loop runs only if the current title matches the regular expression. Since the inner loop is nested inside the first you can still access other properties associated with the current book through book. So the appropriate description node is displayed by accessing book- description. The inner loop comes to an end and the outer loop moves onto the next book. If the regular expression doesn t match the inner loop never runs. One thing you need to be careful about is that even when there is no match match contains a Regexiterator object so you can t use the negative operator empty or is_null to detect a nonmatch. The for loop automatically takes care of nonmatches by skipping them. If you still find this difficult to grasp load into a browser. It displays onscreen the entry and exit points of both loops together with the ordinary output as shown in Figure 7-6. Figure 7-6. Displaying the entry and exit points of each loop shows how the RegexIterator filters the XML data. 258 Simpo PDF Merge and Split Unregistered Version - http SUPERCHARGED LOOPING WITH SPL Displaying messages identifying the current location in a loop is a good way of understanding the flow of a script and it can help with debugging when things don t turn out as expected. Setting options for Regexiterator In addition to the two required arguments the Regexiterator constructor accepts three optional arguments namely Mode This controls how the regular expression is used by emulating the PCRE functions preg_match and preg_match_all . The default is to find a match for the regular expression. Flags There is currently only one flag .