PHP - 全打....

看你们做Permutation好像很好玩,自己也想试试看。。
结果。。。。。变成了全打[s:29][s:29]

$str = “123”;

output就是
111
112
113
121
122
123
131
132
133
211
212
213
221
222
223
231
232
233
311
312
313
321
322
323
331
332
333
27Number

PHP4

<?php class da{ var $str; //the string var $strarr; //splited string (each hold 1 char) var $strarrn; //string array number (use to point to the string) var $lcount; //loop count var $amc; //to determine the max point var $totalcount=0; //juz to count the total display function init() { $this->lcount = strlen($this->str)-1; $this->amc = strlen($this->str)-1; for ($i=0; $istr); $i++) { $this->strarr[] = substr($this->str,$i,1); //spliting the string $this->strarrn[] = 0; //declaire the pointer } } //start the game function show() { $end = false; while (!$end) { $this->pa(); while ($this->lcount>=0) { if ($this->strarrn[$this->lcount]>$this->amc) { $this->strarrn[$this->lcount] = 0; if ($this->lcount>0) { $this->strarrn[$this->lcount-1]++; } else { $end = true; } } $this->lcount--; } $this->lcount = $this->amc; } } //print the array function pa() { foreach ($this->strarrn as $arrn) { print $this->strarr[$arrn]; } print "
"; $this->strarrn[$this->amc]++; $this->totalcount++; } } $word = new da(); $word->str = "123"; $word->init(); $word->show(); print $word->totalcount."Number"; ?>

我是白痴我不懂这些的…><