dedalqq
7/8/2014 - 2:32 PM

gistfile1.php

<?php

class test {

	private $n;
	
	private $m = 0;
	
	private $a = array();
	
	private function i($string) {
		
		if (strlen($string) == $this->n) {
			$this->a[] = $string;
			return;
		}
		
		if (substr($string, -1) != 1) {
			$this->i($string.'1');
		}
		$this->i($string.'0');
	}
	
	public function run($v) {
		
		$this->n = $v;
		$this->i('0');
		$this->i('1');
	
		var_dump($this->a);
	}

}

$test = new test();
$test->run(30);