In: Computer Science
PHP Programming
What is an array?
Select one:
a. a variable that stores multiple values
b. a constant that stores a list of items
c. a list that is stored in multiple variables
d. an index of values
Which of the following is the correct syntax for creating an array?
Select one:
a.
$basket = array(“Watermelon”, “Orange”, “Grape”)
b.
$basket = array(Watermelon, Orange, Grape);
c.
$basket = array($“Watermelon”, $“Orange”, $“Grape”);
d.
$basket = array(“Watermelon”, “Orange”, “Grape”);
What types of items can be stored in arrays?
Select one:
a. integers
b. strings
c. boolean (true/false)
d. all the above
Which of the following accesses the array item by offset?
$myFriends =array("Adam", "Theo", "Adrian");
Select one:
a.
$myFriends[2};
b.
$myFriends[2]
c.
$myFriends{2};
d.
$myFriends{2}
Which of the following outputs the second item in the array $designs?
Select one:
a.
echo $designs[1];
b.
echo $designs{“2”};
c.
echo $designs[2];
d.
echo $designs{2};
From the following php scripting block, what will be displayed in the browser:
<?php
$array[0] = “mall”;
$array[1] = “Kate”;
$array[2] = 9;
$array[3] = “brother”;
$array[4] = “cup cakes”;
$array[5] = “store”;
$array[6] = “Linda”;
echo “$array[1] went to the $array[0] to buy $array[2] $array[4]
for her $array[3].”;
?>
Select one:
a. Linda went to the mall to buy 9 cup cakes for her brother.
b. Kate went to the store to buy 9 cup cakes for her brother.
c. Linda went to the store to buy 9 cup cakes for her brother.
d. Kate went to the mall to buy 9 cup cakes for her brother.
The join() function is synonymous with the implode() function.
Select one:
True
False
The list() function only works on arrays numerically indexed starting at 0.
Select one:
True
False
In the following example the numeric index is automatically assigned?
<?php
$toys = array(“Truck”,”Boat”,”Doll”);
?>
Select one:
True
False
Using the print_r() or var_dump() function, you can view an entire multidimensional array.
Select one:
True
False
Solution:
d. $basket = array(“Watermelon”, “Orange”, “Grape”);
What types of items can be stored in arrays?
d. all the above
Which of the following accesses the array item by offset?
b. $myFriends[2] --should have semicolon
Which of the following outputs the second item in the array $designs?
a. echo $designs[1]; -- array index starts from 0
From the following php scripting block, what will be displayed in the browser:
d. Kate went to the mall to buy 9 cup cakes for her brother.
The join() function is synonymous with the implode() function.
true
The list() function only works on arrays numerically indexed starting at 0.
true
In the following example the numeric index is automatically assigned?
<?php
$toys = array(“Truck”,”Boat”,”Doll”);
?>
true
Using the print_r() or var_dump() function, you can view an entire multidimensional array.
true