hello
i have a php scrpt which generates all possibilities fro a given string
recursive function is used in it. i have given its code below
$charset = "abcd"; $charset_length = strlen($charset); define('MAX_LENGTH', 4); function recurse($width, $position, $base_string) { global $charset, $charset_length; for ($i = 0; $i < $charset_length; ++$i) { if ($position < $width - 1) { recurse($width, $position + 1, $base_string . $charset[$i]); } $string = $base_string . $charset[$i] ; echo "$string<br/>"; } } recurse (MAX_LENGTH, 0, ''); ?>
the output of given code is
aaaa aaab aaac aaad aaa aaba aabb aabc aabd aab aaca aacb aacc aacd aac aada aadb aadc aadd aad aa abaa abab abac abad aba abba abbb abbc abbd abb abca abcb abcc abcd abc abda abdb abdc abdd abd ab acaa acab acac acad aca acba acbb acbc acbd acb acca accb accc accd acc acda acdb acdc acdd acd ac adaa adab adac adad ada adba adbb adbc adbd adb adca adcb adcc adcd adc adda addb addc addd add ad a baaa baab baac baad baa baba babb babc babd bab baca bacb bacc bacd bac bada badb badc badd bad ba bbaa bbab bbac bbad bba bbba bbbb bbbc bbbd bbb bbca bbcb bbcc bbcd bbc bbda bbdb bbdc bbdd bbd bb bcaa bcab bcac bcad bca bcba bcbb bcbc bcbd bcb bcca bccb bccc bccd bcc bcda bcdb bcdc bcdd bcd bc bdaa bdab bdac bdad bda bdba bdbb bdbc bdbd bdb bdca bdcb bdcc bdcd bdc bdda bddb bddc bddd bdd bd b caaa caab caac caad caa caba cabb cabc cabd cab caca cacb cacc cacd cac cada cadb cadc cadd cad ca cbaa cbab cbac cbad cba cbba cbbb cbbc cbbd cbb cbca cbcb cbcc cbcd cbc cbda cbdb cbdc cbdd cbd cb ccaa ccab ccac ccad cca ccba ccbb ccbc ccbd ccb ccca cccb cccc cccd ccc ccda ccdb ccdc ccdd ccd cc cdaa cdab cdac cdad cda cdba cdbb cdbc cdbd cdb cdca cdcb cdcc cdcd cdc cdda cddb cddc cddd cdd cd c daaa daab daac daad daa daba dabb dabc dabd dab daca dacb dacc dacd dac dada dadb dadc dadd dad da dbaa dbab dbac dbad dba dbba dbbb dbbc dbbd dbb dbca dbcb dbcc dbcd dbc dbda dbdb dbdc dbdd dbd db dcaa dcab dcac dcad dca dcba dcbb dcbc dcbd dcb dcca dccb dccc dccd dcc dcda dcdb dcdc dcdd dcd dc ddaa ddab ddac ddad dda ddba ddbb ddbc ddbd ddb ddca ddcb ddcc ddcd ddc ddda dddb dddc dddd ddd dd d
i mean it generates all possibilities from a string "abcd" now i want that this code generate result which must have the possibilites of minimum 3 characters and above
now i want that this code generates all possibilites having minimum three charters like aaa bbb aab acc add abd abc aaaa aaab aaad dabb. i mean the code must ommit all one or two charcter string (i.e., a aa b bb cd dc ......) from the result
how i do that please help
can anyone write recursive function for generating alphanumeric string ?