Example #1
0
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
Example #2
0
        $this->stringTemp = $stringTemp;
        $firstOccurence = $this->firstOccurence;
        $nextOccurence = $this->nextOccurence;
        $numberOfOccurence = $this->numberOfOccurence;
        if ($stringTemp) {
            for ($i = 0; $i < $stringLength; $i++) {
                if ($stringTemp[$i] == $stringTemp[$firstOccurence] && $firstOccurence != $i) {
                    //echo $stringTemp[$i]." ".$i.PHP_EOL;
                    $nextOccurence = $i;
                    $numberOfOccurence = ceil($stringLength / ($nextOccurence - $firstOccurence));
                    break;
                }
            }
            //echo $firstOccurence." ".$nextOccurence." ".$numberOfOccurence.PHP_EOL;
            $this->nextOccurence = $nextOccurence;
            //update occurence
            $this->numberOfOccurence = $numberOfOccurence;
            //update occurence
            $this->getMatch();
        }
        return $this->hasSubstring;
    }
}
if (count($argv) > 1) {
    $argument1 = $argv[1];
    $test = new Substring();
    var_dump($test->getString($argument1));
    var_dump($test->stringOfForm());
} else {
    echo "Usage: php index.php {string_to_test}";
}