3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function parseTicketName($ticketName) { global $sites; $system = substr($ticketName, 0, 2); // pull out managment system $ticketName = substr($ticketName, 2); // remove management system // Find first occurence of number $firstNumber = strcspn($ticketName, '0123456789'); // Get project name $project = substr($ticketName, 0, $firstNumber); // Get ticket ID $ticket_id = substr($ticketName, $firstNumber); // remove project, and only thing left is ticket ID return array('system' => $system, 'project' => $project, 'ticket_id' => $ticket_id); } // 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 4.3.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(3) { ["system"]=> string(2) "AS" ["project"]=> string(2) "FX" ["ticket_id"]=> string(2) "10" }
Output for 4.3.0 - 4.3.1
array(3) { ["system"]=> string(2) "AS" ["project"]=> string(0) "" ["ticket_id"]=> string(4) "FX10" }