fork download
  1. <?
  2.  
  3. $str = 'string|name1,value1|name2,value2|name3,value3|';
  4.  
  5. preg_match_all('#\b(\w+)\b#', $str, $matches);
  6.  
  7. var_dump($matches);
  8.  
  9. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  array(7) {
    [0]=>
    string(6) "string"
    [1]=>
    string(5) "name1"
    [2]=>
    string(6) "value1"
    [3]=>
    string(5) "name2"
    [4]=>
    string(6) "value2"
    [5]=>
    string(5) "name3"
    [6]=>
    string(6) "value3"
  }
  [1]=>
  array(7) {
    [0]=>
    string(6) "string"
    [1]=>
    string(5) "name1"
    [2]=>
    string(6) "value1"
    [3]=>
    string(5) "name2"
    [4]=>
    string(6) "value2"
    [5]=>
    string(5) "name3"
    [6]=>
    string(6) "value3"
  }
}