Hi, I’m trying to turn input from textarea into an array
here is what the textarea input look like
[input 1] [input 2] [input 3]
I’m trying to split everything inside the square bracket “” into an array.
here are my codes
$option = array();
$regex = "#[\\[^]]*#s";
$input = "[input 1] [input 2] [input 3]";
$option = preg_split($regex, $input, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
the output is
Array
(
[0] => input 1]
[1] => input 2]
[2] => input 3]
)
the closing bracket still there, So what am I missing the regex pattern? Thanks