Jump to content

Recursive Function, Return Array not working


Recommended Posts

I'm trying to return to array of letters that bruteForce finally decides upon. However, I can't seem to pass the array to librarySolve.


I'm feeling dumb, any help?


function librarySolve($string){
$temp = $this->bruteForce($string, FALSE, 0);
return $temp;

function bruteForce($string, $state, $trys){
$base = $string;
$state = $state;
$new_letters = array();

if($trys <= 6000){
	$this->new_letters = $this->generateRandomCipher();
	$string = preg_replace('/[^a-zA-Z0-9-\s]/', '', $string);

		$letter = substr($string, $a, 1);
		$pattern = "/[A-Z]/";

		if(preg_match($pattern, $letter)!=0){
			$new_letter = $this->new_letters[$letter];
		} else if(preg_match($pattern, $letter)==0) {
				$new_letter = $letter;
		$decipher .= $new_letter;

	$word_array = explode(" ", $decipher);

	$count = 0;
		$do = $this->checkWord($word_array[$a]);

	if($count>=2){ $state = TRUE; } else { $state = FALSE; }

		return $this->new_letters;
	} else {
		$this->bruteForce($base, $state, $trys);

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.