fork(1) download
  1. <?php
  2. $re = '/(\w+)\=\"([a-zA-Z0-9 ,.\/&%?=]+)\"/m';
  3. $str = '<match id="18" srs="ICC Womens World Cup Qualifier, 2010" mchDesc="BANW vs PMGW" mnum="4th Match">
  4. <match id="18" type="ODI" srs="ICC Womens World Cup Qualifier, 2017" mchDesc="BANW vs PMGW" mnum="4th Match, Group B" vcity="Colombo" vcountry="Sri Lanka" grnd="Colombo Cricket Club Ground" inngCnt="0" datapath="google.com/j2me/1.0/match/2017/"
  5. ';
  6.  
  7. preg_match_all($re, $str, $matches);
  8.  
  9. $c = array_combine($matches[1], $matches[2]);
  10.  
  11. print_r($c);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [id] => 18
    [srs] => ICC Womens World Cup Qualifier, 2017
    [mchDesc] => BANW vs PMGW
    [mnum] => 4th Match, Group B
    [type] => ODI
    [vcity] => Colombo
    [vcountry] => Sri Lanka
    [grnd] => Colombo Cricket Club Ground
    [inngCnt] => 0
    [datapath] => google.com/j2me/1.0/match/2017/
)