<?php $string = "some text here [baz] and here [you|him|her|foo|bar|baz|foo|option|test] and even here [another]."; // Capture strings between brackets preg_match_all('~\[([^]]+)]~', $string, $matches); $groups = []; foreach ($matches[1] as $values) { // Explode them on pipe $groups[] = explode('|', $values); } print_r($groups);
You have javascript disabled. You will not be able to edit any code.