$text = '{Привет|[Привет|Здравствуй|Хай|Здаров]|Не привет|[Один|Два]}';
preg_match_all('#\[(.*)\]#isU', $text, $matches);
$words = [];
foreach ($matches[1] as $val) {
$str = explode('|', $val);
$words[] = $str[array_rand($str)];
}
$text = str_replace($matches[0], $words, $text);
preg_match('#\{(.*)\}#isU', $text, $matches);
$words1 = explode('|', $matches[1]);
shuffle($words1);
echo implode('|', $words1);