eval.in

Paste #82159

PHP — PHP 5.5.1, pasted 5 years ago (json)

1
2
3
4
5
6
<?php

$test = 'arg1="value1" arg2="value2" arg3="value3 value4 value5"';
preg_match_all('#([a-zA-Z0-9]+)="([^"]+)"#', $test, $matches);

var_dump($matches);

Program Output

array(3) {
  [0]=>
  array(3) {
    [0]=>
    string(13) "arg1="value1""
    [1]=>
    string(13) "arg2="value2""
    [2]=>
    string(27) "arg3="value3 value4 value5""
  }
  [1]=>
  array(3) {
    [0]=>
    string(4) "arg1"
    [1]=>
    string(4) "arg2"
    [2]=>
    string(4) "arg3"
  }
  [2]=>
  array(3) {
    [0]=>
    string(6) "value1"
    [1]=>
    string(6) "value2"
    [2]=>
    string(20) "value3 value4 value5"
  }
}

OK (0.008 sec real, 0.007 sec wall, 14 MB, 103 syscalls)

Fork