Location: PHPKode > scripts > Text Iterator > text-iterator/example1.php
<?php
/**
* Brute Force Search Class
*
*
*     __     __)               _____                      ___
*    (, /|  /  ,              (, /     /)           ,    (,   )      /)    /)
*      / | /    ___   _         /  ___(/   _   __            / _   _(/  _ (/
*   ) /  |/  _(_// (_(_(_   ___/__(_) / )_(_(_/ (__(_      _/_(_(_(_(__(/_/ )_
*  (_/   '                /   /                         )   /
*                        (__ /                         (__ /
* ****************************************************************************
* @author    Nima Johari Zadeh <nijoza91-at-gmail-dot-com>
* @package   Brute Force Search Class
* @file      example1.php
* @copyright (c) 2007 Nima Johari Zadeh
* ****************************************************************************
* This example not that twisted!
* It only demonstrates the class's functionality!
*/

@set_time_limit(0); //This might be useful. Searching might take too long!

header("Content-Type: text/plain");
require_once("brute_force.class.php");

function example_callback($arg1, $i)
{
    echo $i . ": " . $arg1 . "\n";
}

$vals = array("n", "i", "m", "a");
$brute_force = new brute_force("example_callback", 4, 4, $vals);
if(!$brute_force->errormsg())
{
    $brute_force->callback_break = false; //This indicates that searching would not be terminated by the callback function, By setting this to true, process will terminate whenever callback function returns true (refer to the documentation)
    $brute_force->search();
}
else
{
    echo "Brute Force Problem: " . $brute_force->errormsg() . "\n";
}
?>
Return current item: Text Iterator