Created
September 18, 2019 15:24
-
-
Save phpfiddle/bd2a5f33ad751a1d754e2a237f87b64f to your computer and use it in GitHub Desktop.
[ Posted by Expangea ] PHP preg_match_all xml tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. <code>Donec sed erat</code> vel diam ultricies commodo. | |
Nunc venenatis tellus eu quam suscipit quis fermentum <code>dolor vehicula.</code> fin"; | |
$regex=''; | |
$regex = '#<\s*?code\b[^>]*>(.*?)</code\b[^>]*>#s'; | |
$code = preg_match_all($regex, $text, $matches); | |
echo $text."<hr>"; | |
echo var_export($matches,true); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment