3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function parseTicketName($ticketName) { global $sites; $system = substr($ticket, 0, 2); // pull out managment system $ticketName = substr($ticketName, 2); // remove management system preg_match('/^([[:alpha:]]+)([[:digit:]]+)$/', $ticketName, $matches); return array( 'system' => $system, 'project' => $matches[1], 'ticket_id' => $matches[2] ); } // 2 first characters is system, then the next letters are project name and the numbers are the ticket id $s = "ASFX10"; var_dump(parseTicketName($s));
Output for 7.0.0 - 7.1.0
Notice: Undefined variable: ticket in /in/ffZL7 on line 5 array(3) { ["system"]=> string(0) "" ["project"]=> string(2) "FX" ["ticket_id"]=> string(2) "10" }
Output for hhvm-3.13.2
Notice: Undefined variable: ticket in /in/ffZL7 on line 5 Warning: substr() expects parameter 1 to be string, null given in /in/ffZL7 on line 5 array(3) { ["system"]=> NULL ["project"]=> string(2) "FX" ["ticket_id"]=> string(2) "10" }
Output for hhvm-3.12.0
Notice: Undefined variable: ticket in /in/ffZL7 on line 5 Warning: substr() expects parameter 1 to be string, null given in /in/ffZL7 on line -1 array(3) { ["system"]=> NULL ["project"]=> string(2) "FX" ["ticket_id"]=> string(2) "10" }
Output for 5.0.4 - 5.6.28, hhvm-3.10.0
Notice: Undefined variable: ticket in /in/ffZL7 on line 5 array(3) { ["system"]=> bool(false) ["project"]=> string(2) "FX" ["ticket_id"]=> string(2) "10" }
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: ticket in /in/ffZL7 on line 5 array(3) { ["system"]=> bool(false) ["project"]=> string(2) "FX" ["ticket_id"]=> string(2) "10" }