I have pretty long string to parse, that looks like that (part of it)
$string = 'FIRM_ID = MC0356400000; TAG = EQTV; CURR_CODE = SUR; CLIENT_CODE = FR334; LIMIT_KIND = 1; OPEN_BALANCE = 4822.84; OPEN_LIMIT = 0.00; LEVERAGE = 0;'
I need to get values for php variables from that string, which I do with preg_match:
preg_match("/FIRM_ID = (.*?);/", $string, $m);
$firm_id = trim($m[1]);
preg_match("/CLIENT_CODE = (.*?);/", $string, $m);
$client_code = trim($m[1]);
... and so on
I was wondering is there a way to do the same in one line? May be with preg_replace or other functions, so I would not have to declare $m variable first and then take out from that [1] element.
So the code supposed to look like
$firm_id = somefunction($string);
$client_code = somefunction($string);
Its not practical question, more theoretical. I know how to get result that I need, I want to know if there is a simpler and more elegant way.
Thanks.