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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -