查看完整版本 : 有關PHP preg_match_all

hkhome 2018-9-3 02:59 PM

有關PHP preg_match_all

各位師兄好

我有一堆字串如下
{"inv":[{"HSBC":"AAA","value":"10000"},{"HSBC":"BBB","value":"20000"},{"HSBC":"HHH","value":"30000"},{"HSBC":"CCC","value":"40000"},{"HSBC":"III","value":"50000"},{"HSBC":"DDD","value":"60000"},{"HSBC":"JJJ","value":"70000"},{"HSBC":"EEE","value":"80000"},{"HSBC":"KKK","value":"90000"},{"HSBC":"FFF","value":"100000"},{"HSBC":"LLL","value":"110000"},{"HSBC":"GGG","value":"120000"}]}

我用 preg_match_all( '!(\d+\.\d+)|(\d+\-\d+)|(\d+)!', $data, $pieces);
echo $pieces[0][0] 佢會出到10000.
請問如何可以處理埋AAA,BBB,CCC個啲入去array??

萬分感謝

form5 2018-9-3 10:09 PM

'!(\d+\.\d+)|(\d+\-\d+)|(\d+)!'
Match 吾到 10000

'^(\d+\.\d+)|(\d+\-\d+)|(\d+)$'
Match 到

邊度抄返黎?
頁: [1]
查看完整版本: 有關PHP preg_match_all