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);
for($a=0;$a<=strlen($string);$a++){
$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;
for($a=0;$a<count($word_array);$a++){
$do = $this->checkWord($word_array[$a]);
if(!empty($do)){
$count++;
}
}
if($count>=2){ $state = TRUE; } else { $state = FALSE; }
if($state==TRUE){
return $this->new_letters;
} else {
$trys++;
$this->bruteForce($base, $state, $trys);
}
}
}