例如这是我的文字:
$str = 'buy new microsoft windows';
我用数组爆炸文本和列表:
Array ( [0] => buy [1] => new [2] => microsoft [3] => windows )
buy new buy new windows buy microsoft buy microsoft windows buy windows new microsoft new microsoft windows new windows microsoft windows
你可以看看这个
PEAR PACKAGE
使用示例
原文链接:https://www.f2er.com/php/138166.html使用示例
<?PHP require_once 'Math/Combinatorics.PHP'; $words = array('buy','new','microsoft'); $combinatorics = new Math_Combinatorics; foreach($combinatorics->permutations($words,2) as $p) { echo join(' ',$p),"\n"; }
输出结果为:
buy new new buy buy microsoft microsoft buy new microsoft microsoft new