3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $filesets[] = 'Include { Options { signature = MD5 } file = /backup } Exclude { file = /backup/elasticsearch }'; $filesets[] = 'Include { Options { wildfile = "/backup/*/" } Options { ...another set of options... } file = /backup }'; $filesets[] = 'Include { file = /backup/a } Include { file = /backup/b }'; $filesets[] = 'Exclude { file = /backup/raw } Include { file = /backup }'; foreach ($filesets as $c) { var_dump(getFolders($c)); echo "\n\n"; } function getFolders($content) { $content = str_replace(array("\n", " "), array('', ''), $content); // remove options $content = preg_replace('/Options{+(.*?)}/i', '', $content); // match include files if (!preg_match_all('/Include{file=(.*?)}/i', $content, $matches)) { echo "NOPE"; } $folders = explode('file=', $matches[1]); array_shift($folders); return $folders; }
based on GF9fi
Output for 5.3.1 - 5.6.28, 7.0.0 - 7.1.0
Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be array, null given in /in/RmY9I on line 40 NULL Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be array, null given in /in/RmY9I on line 40 NULL Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be array, null given in /in/RmY9I on line 40 NULL Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be array, null given in /in/RmY9I on line 40 NULL
Output for hhvm-3.10.0 - 3.12.0
Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be an array or mutable collection in /in/RmY9I on line 40 NULL Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be an array or mutable collection in /in/RmY9I on line 40 NULL Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be an array or mutable collection in /in/RmY9I on line 40 NULL Warning: explode() expects parameter 2 to be string, array given in /in/RmY9I on line 39 Warning: array_shift() expects parameter 1 to be an array or mutable collection in /in/RmY9I on line 40 NULL
Output for 4.3.0 - 5.3.0
Notice: Array to string conversion in /in/RmY9I on line 39 array(0) { } Notice: Array to string conversion in /in/RmY9I on line 39 array(0) { } Notice: Array to string conversion in /in/RmY9I on line 39 array(0) { } Notice: Array to string conversion in /in/RmY9I on line 39 array(0) { }