Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Short answer 1. When using sessions in PHP to manage login information, why is i

ID: 641107 • Letter: S

Question

Short answer

1. When using sessions in PHP to manage login information, why is it critical to always

use an encrypted https connection?

2. Given the following snippet of code, at what index value is the last string stored?

$arr = array();

$arr[4] = 'four';

$arr['three'] = 3;

$arr[] = 'What's my index?';

Programming

3. Write a function removeAllValuesMatching($arr, $value) that takes an

associative array and a value as a parameter and returns a new associative array in which any

array value matching $value is removed. In other words,

$arr = array(

'a' => "one",

'b' => "two",

'c' => "three",

'd' => "two",

'e' => "four",

'f' => "five",

'g' => "three",

'h' => "two"

);

print_r(removeAllValuesMatching($arr, "two"));

would print:

Array

(

[a] => one

[c] => three

[e] => four

[f] => five

[g] => three

)

2

4. Write a function removeDuplicates($arr) that takes an associative array as a

parameter and returns the same associative array except with all duplicate values removed.

You may not use the function array_unique for this problem. For example:

$arr = array(

'a' => "one",

'b' => "two",

'c' => "three",

'd' => "two",

'e' => "four",

'f' => "five",

'g' => "three",

'h' => "two"

);

print_r(removeDuplicates($arr));

Would print:

Array

(

[a] => one

[e] => four

[f] => five

)

5. Write a function findSpellings($word, $allWords) that takes a string and an

array of dictionary words as parameters. The function should return an array of possible

spellings for a misspelled $word. One way to approach this is to use the soundex() function

to find words in $allWords that match the soundex for $word.

Explanation / Answer

1.

By default all HTTP traffic crosses the wire in an unencrypted, plain text, mode. Thus, any device with access to the same wire or shared network devices is capable of

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote