3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $class = 'Zend\Ha\Heee'; $matches = array(); preg_match('/(?P<namespace>.+\\\)?(?P<class>[^\\\]+$)/', $class, $matches); $class = (isset($matches['class'])) ? $matches['class'] : ''; $namespace = (isset($matches['namespace'])) ? $matches['namespace'] : ''; var_dump($matches, $class, $namespace);
Output for 4.3.3 - 5.6.22, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(5) { [0]=> string(12) "Zend\Ha\Heee" ["namespace"]=> string(8) "Zend\Ha\" [1]=> string(8) "Zend\Ha\" ["class"]=> string(4) "Heee" [2]=> string(4) "Heee" } string(4) "Heee" string(8) "Zend\Ha\"
Output for 4.3.0 - 4.3.2
array(3) { [0]=> string(12) "Zend\Ha\Heee" [1]=> string(8) "Zend\Ha\" [2]=> string(4) "Heee" } string(0) "" string(0) ""