[ create a new paste ] login | about

Link: http://codepad.org/Dc87oia1    [ raw code | output | fork ]

PHP, pasted on Mar 29:
1
2
3
4
<?php
$str = 'this is a string  "that has quoted text" "" inside.';
var_dump ( preg_split('#\s+("[^"]*")\s+|\s+#', $str, -1 , PREG_SPLIT_DELIM_CAPTURE) );
?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
array(7) {
  [0]=>
  string(4) "this"
  [1]=>
  string(2) "is"
  [2]=>
  string(1) "a"
  [3]=>
  string(6) "string"
  [4]=>
  string(22) ""that has quoted text""
  [5]=>
  string(2) """"
  [6]=>
  string(7) "inside."
}


Create a new paste based on this one


Comments: