php - Easily extract data from string formatted a specific way -
what easy way take string formatted way:
c:7|bn:99
and able use string easily? if wanted number behind c:, how easily. same, thing number behind bn:?
$arr = array(); $str = "c:7|bn:99"; $tmp1 = explode('|', $str); foreach($tmp1 $val) { $tmp2 = explode(':', $val); $arr[$tmp2[0]] = $tmp2[1]; } //print ur array print_r($arr); //accessing specifc value echo $arr['c']." ".$arr['bn'];
Comments
Post a Comment