Question

In: Computer Science

PHP Programming What is an array? Select one: a. a variable that stores multiple values b....

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

Solutions

Expert Solution

Solution:

  • What is an array :-
    • a. a variable that stores multiple values
  • Which of the following is the correct syntax for creating an array?
    • 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



Related Solutions

Java programming language Array - Single identifier which can store multiple values Example initialized with values:...
Java programming language Array - Single identifier which can store multiple values Example initialized with values: int[] mySimpleArray = {4, 17, 99}; Example with fixed length but no values: int[] myFixedArray = new int[11]; The brackets identify the index. Each value has its own index number. NOTE: First element is the zeroth element: mySimpleArray[0] is 4, [1] is 17 Make a new Netbeans project called ArraysAndLoops Create the simple array with 4, 17, 99. Use System.out.println with the variable with...
Programming in C++ Write a program that prints the values in an array and the addresses...
Programming in C++ Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
Write a class DataSet that stores a number of values of type double in an array...
Write a class DataSet that stores a number of values of type double in an array list. Provide methods to insert a value to the array list and to compute the sum, average, and maximum value. Please put a note on what you did is for what. So I can understand this question better. Code provided: import java.util.*; public class DataSet {    private ArrayList<Double> data; /** Constructs an empty data set. @param maximumNumberOfValues the maximum this data set can...
Programming in C:- 1. Suppose that a variable 's' is an array of strings (i.e. a...
Programming in C:- 1. Suppose that a variable 's' is an array of strings (i.e. a pointer array where each element points to a string). Write an expression that obtains the length of the third string of 's'. You may assume that string.h has been included. 2. Consider the following function whose purpose is to return an array of 3 strings that are initialized to the strings in the character arrays s1, s2, and s3: #include <string.h> #include <stdlib.h> char**...
This is C++ programming Given an int variable k, an int array incompletes that has been...
This is C++ programming Given an int variable k, an int array incompletes that has been declared and initialized, an int variable nIncompletes that contains the number of elements in the array, an int variable studentID that has been initialized, and an int variable numberOfIncompletes, Write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes. You may use only k, incompletes, nIncompletes, studentID, and numberOfIncompletes. I tried this code...
in C programming language char character [100] = "hello"; a string array variable It is given....
in C programming language char character [100] = "hello"; a string array variable It is given. By writing a function called TranslateString, By accessing the pointer address of this given string, returning the string's address (pointer address) by reversing the string Write the function and use it on the main function. Function void will not be written as. Return value pointer address it will be. Sweat operation on the same variable (character) It will be made. Declaration of the function...
What is the first step of the programming process? Select one: a. Survey, interview, or observe...
What is the first step of the programming process? Select one: a. Survey, interview, or observe employees to determine needs. b. Define the scope, goals, or success criteria for the programming. c. Obtain approval to perform programming from sponsors. d. Set a schedule and deadlines for programming tasks. A statement of requirements _____. Select one: a. for design is an internally produced space planning and relocation forecast. b. lists alternative options for enacting the goals of the strategic facility plan....
Post a Python program that contains an array variable whose values are input by the user....
Post a Python program that contains an array variable whose values are input by the user. It should the perform some modification to each element of array using a loop and then the modified array should be displayed. Include comments in your program that describe what the program does. Also post a screen shot of executing your program on at least one test case.
Activity 12: Array What is an Array? An array is a special variable, which can hold...
Activity 12: Array What is an Array? An array is a special variable, which can hold more than one value at a time. If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this: var car1 = "Saab"; var car2 = "Volvo"; var car3 = "BMW"; However, what if you want to loop through the cars and find a specific one? And what if you had not...
C# Programming using Windows Form 1. Define a variable named isTrue that stores a value of...
C# Programming using Windows Form 1. Define a variable named isTrue that stores a value of whether something is true or false. Set this variable    to the negative. Output this variable to the txtIsTrue textbox. 2. Define a variable named favoriteGame that could store the name of a game. Set this variable's value to your favorite game. Output this variable to the txtFavoriteGame textbox. 3.. Define a variable named pi that can store real numbers. initialize it to a value...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT