3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $regex = '/^\s*<\S+\s*\S*>[\s\S]*?(?:^\s*<\/\S+>)|([\s\S]+\n)/m'; $vhost = ' DocumentRoot /www/example2 ServerName www.example.org ErrorLog /var/log/log.txt <Directory> ErrorLog /var/log/log.txt </Directory> <Directory /> ErrorLog /var/log/log.txt </Directory>'; preg_match_all($regex, $vhost, $matches); var_dump($matches);
based on vV4MU
Output for 4.3.0 - 7.1.0
array(2) { [0]=> array(1) { [0]=> string(192) " DocumentRoot /www/example2 ServerName www.example.org ErrorLog /var/log/log.txt <Directory> ErrorLog /var/log/log.txt </Directory> <Directory /> ErrorLog /var/log/log.txt " } [1]=> array(1) { [0]=> string(192) " DocumentRoot /www/example2 ServerName www.example.org ErrorLog /var/log/log.txt <Directory> ErrorLog /var/log/log.txt </Directory> <Directory /> ErrorLog /var/log/log.txt " } }