用php从文章中选择随机单词

I'd like to create a script for generating different content for my products. For example, my first product content is:

Acer 5520G Notebook using 15.6 LCD Panel.

Second one is;

Acer 5720G Laptop using 15.6 Screen.

I want to create my articles like:

Acer (5520G|5720G) (Laptop|Notebook) using 15.6 (LCD Panel|Screen)

And then, randomise all words written in (..) with php.

I did randomised words with;

$strings = '5520G, 5720G';
$key = array_rand($strings);
echo $strings[$key].

But I could'nt select (..) words from my articles, so any suggestions?

Can you use JSON?

$items = json_decode('["Acer",["5520G","5720G"],["Laptop","Notebook"],"using 15.6",["LCD Panel","Screen"]]', true);

$out = array();
foreach($items as $item){
    if(is_array($item)){
        shuffle($item);
        $out[] = $item[0];
    }else{
        $out[] = $item;
    }
}

echo implode(' ', $out);

You are trying to use an array function on a string. Try this:

$strings = array('5520G', '5720G');
$key = array_rand($strings);
echo $strings[$key];