Coastal_Life Posted January 17, 2014 Share Posted January 17, 2014 I am trying to parse information from a FL drivers license Magnetic Strip. The information below should explain better. These are the numbers in the stip: ;6360101262000786187=2105197499270=? I have made bold (above) the numbers needed from the string. Actual numbers: 86 05 27 Placement in the string counting from left to right (including all charactors): 16 & 17 24 & 25 32 & 33 function get_age($birth_date){ return floor((time() - strtotime($birth_date))/31556926); } echo get_age("1986-05-27"); Any thoughts? Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/285450-parsing-dl-codes/ Share on other sites More sharing options...
Ch0cu3r Posted January 17, 2014 Share Posted January 17, 2014 If you know the positions then use substr $DL = ';6360101262000786187=2105197499270=?'; $numbers = array(); // number positions $postions = array(15, 23, 31); // loop over the positons foreach($postions as $postion) { // get the number $numbers[] = substr($DL, $postion, 2); } printf('<pre>%s</pre>', print_r($numbers, true)); Link to comment https://forums.phpfreaks.com/topic/285450-parsing-dl-codes/#findComment-1465585 Share on other sites More sharing options...
Coastal_Life Posted January 17, 2014 Author Share Posted January 17, 2014 Thank you very much. That worked perfectly. Link to comment https://forums.phpfreaks.com/topic/285450-parsing-dl-codes/#findComment-1465586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.