} // create an array to store the words $wordsPicked = array(); // make sure that the $numberOfWords is valid if ($numberOfWords <= 0 || $numberOfWords > 4) { return; } else { if ($includeNumber && $specialCharacter) { generatePassword($numberOfWords, $wordList); $wordsPickedAndNumber = addNumber($wordsPicked); $wordsPickedFinal = addCharacter($wordsPickedAndNumber); $passwordString = printPassword($wordsPickedFinal, $passwordString); } else { if ($includeNumber) { generatePassword($numberOfWords, $wordList); $wordsPicked = addNumber($wordsPicked); $passwordString = printPassword($wordsPicked, $passwordString); } else { if ($specialCharacter) { generatePassword($numberOfWords, $wordList); $wordsPicked = addCharacter($wordsPicked); $passwordString = printPassword($wordsPicked, $passwordString); } else { //$wordsPicked = generatePassword($numberOfWords, $wordsPicked, $wordList); generatePassword($numberOfWords, $wordList); $passwordString = printPassword($wordsPicked, $passwordString); } } } } /*
</i></h2> <?php global $addSymbol; if (isset($_POST['addSymbol'])) { $addSymbol = addSymbol(); } ?> <h2 class="phrase"><strong>Random Phrase Generated with a Symbol: </strong><i><?php echo $addSymbol; ?> </i></h2> <?php global $addNumber; if (isset($_POST['addNumber'])) { $addNumber = addNumber(); } ?> <h2 class="phrase"><strong>Random Phrase Generated with a Number: </strong><i><?php echo $addNumber; ?> </i></h2> <?php global $upperCase; if (isset($_POST['upperCase'])) { $upperCase = upperCase(); } ?> <h2 class="phrase"><strong>Random Phrase Generted with an Upper Case: </strong><i><?php
<?php function swap(&$a, &$b) { $temp = $b; $b = $a; $a = $temp; } function minHeapFixup(array &$a, $i) { for ($j = (int) (($i - 1) / 2); $j >= 0 && $i != 0 && $a[$i] < $a[$j]; $i = $j, $j = (int) (($i - 1) / 2)) { swap($a[$i], $a[$j]); } /*$j = (int)(($i-1)/2); while ( $j>=0 && $i!=0 && $a[$i]<$a[$j] ) { swap($a[$i], $a[$j]); $i=$j; $j=(int)(($i-1)/2); }*/ } function addNumber(array &$a, $i, $value) { $a[$i] = $value; minHeapFixup($a, $i); } /* $a = 1, $b = $a+1; var_dump($b);*/ $array = [2, 4, 6]; addNumber($array, 3, 1); var_dump($array);
<?php include "common.php"; if (isset($_GET['add'])) { //Clicked button was add button addNumber(); } elseif (isset($_POST['delete'])) { //Clicked button was delete button deleteNumber(); } elseif (isset($_POST['update'])) { //Clicked button was update button updateNumber(); } function addNumber() { $name = $_GET["name"]; $surname = $_GET["surname"]; $email = $_GET["email"]; $phoneType = $_GET["phone-type"]; $phoneNumber = $_GET["phonenumber"]; $address = $_GET["address"]; // Checks if user exist $file = fopen("phonebook.txt", "r") or exit("Unable to open file!"); while (!feof($file)) { $line = fgets($file); $line = explode("\t", $line); //Last Index number is needed for addition $maxindex = 0; $current = intval($line[0]); if ($maxindex < $line[0]) { $current = intval($line[0]);