Example,
The code is as follows: |
Copy code |
<? Php $ Fcontents = "fdsafdafdsa {page} {/page} dafdsafdsafdsafdsa "; If (eregi ("{page} (. *) {/page}", $ fcontents, $ regs )){ // Echo "successful "; // Print_r ($ regs ); Echo $ regs [1]; } Else { Echo "failed "; } Exit; ?> |
Output result
Coming from China
What if we put multiple labels in the test?
The code is as follows: |
Copy code |
<? Php $ Fcontents = "fdsafdafdsa {page} China yes {/page} dafdsafdsafdsafdsa {page} Hello China {/page} fdsafdsafsda {page} I love china {/page} fdafdsa "; If (eregi ("{page} (. *) {/page}", $ fcontents, $ regs )){ // Echo "successful "; // Print_r ($ regs ); Echo $ regs [1]; } Else { Echo "failed "; } Exit; ?>
|
Output result
Please visit china {/page} dafdsafdsafdsafdsa {page} Hello China {/page} fdsafdsafsda {page} I love China
I found that there was a problem with this closure. I haven't thought of a solution yet.