I'm starting a project to update our XML schema for the SOAP interface for the company I work for. Looking at the XML schemas at w3c I've noticed there's a specific datatype for duration. We currently use "HH:MM:SS" to specify duration, as opposed to 'P5Y2M10D'
The Snr Developer above me has said he'd like to keep everything consistent across the system, which I also agree with, but a little part of me would like to maintain a w3c compliant system. So with that in mind, are there any functions in PHP to parse the xml duration datatype to a mysql c开发者_C百科ompatible format?
I don't think there are any built-in functions to parse that format, but you could parse it with preg_split()
$dur = preg_split('/[a-z]/i', $dur_in_xml_format);
$dur = array_slice($dur, 1, count($dur) - 2);
Once in an array, you can format it any way you want very easily.
精彩评论