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(0) "" [1]=> string(0) "" ["class"]=> string(12) "Zend_Ha_Heee" [2]=> string(12) "Zend_Ha_Heee" } string(12) "Zend_Ha_Heee" string(0) ""
Output for 4.3.0 - 4.3.2
array(3) { [0]=> string(12) "Zend_Ha_Heee" [1]=> string(0) "" [2]=> string(12) "Zend_Ha_Heee" } string(0) "" string(0) ""