fork download
  1. <?php
  2.  
  3. $input = "
  4. anythingHere \"Can you see me?\"
  5. ...random code
  6. someArray[] = [\"Come and\",
  7. \"get me,\",
  8. \"or fail\",
  9. \"trying!\",
  10. \"Yours truly\"]
  11. random code...
  12. \"some string\"
  13. ";
  14.  
  15. preg_match_all('/(?:(?s).*someArray\[\].*?=.*?\[|\G[^"\]]+)"(.*?)"/', $input, $matches);
  16. $array_items = $matches[1];
  17. var_dump($array_items);
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
array(5) {
  [0]=>
  string(8) "Come and"
  [1]=>
  string(7) "get me,"
  [2]=>
  string(7) "or fail"
  [3]=>
  string(7) "trying!"
  [4]=>
  string(11) "Yours truly"
}