Question

Create a php program that contains a multi-dimensional array called package. package contains the following arrays:...

Create a php program that contains a multi-dimensional array called package.

package contains the following arrays:

  • colors; which has the values of at least 4 colors
  • sizes; which has the values of at least 4 sizes
  • locations; which has the values of at least 4 locations
  • transport; which has the values of at least 4 types of transport

The program should display a random sentence containing one value of, size, color, locations and transport.

this is for web 2- php

thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

<?php

error_reporting(0);

// function to get random number between 0 and b

function r($b){

  $val=rand(0,$b-1);

  return $val;

}

// declared 2d array

$package = array

(

array("Red","Green","Blue","Yellow","Pink"),

array(15,13,10,5,4,8,10),

array("Berlin","Cincinati","Moscow","Denver"),

array("bus","car","bike","cycle","auto")

);

  // concatenating sentence with the array bike getting random value in the length range

  // to get random elements

  echo "I will go to ".$package[2][r(count($package[2]))] ." in a ".$package[0][r(count($package[0]))]." ".$package[3][r(count($package[3]))]." wearing my ".$package[1][r(count($package[1]))]." inch long boot";

?>

2 4 5 6 7 <?php error_reporting(); // function to get random number between @ and b function r($){ $val=rand(@,$b-1); return

OUTPUT:

I will go to Denver in a Green car wearing my boot 5 inch long boo

I will go to Berlin in a Red bike wearing my 5 inch long boot?

Please upvote if you like my answer and comment below if you have any queries.

Add a comment
Know the answer?
Add Answer to:
Create a php program that contains a multi-dimensional array called package. package contains the following arrays:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • array function • Create a function called show2D. • This function should accept a two-dimensional array...

    array function • Create a function called show2D. • This function should accept a two-dimensional array as parameter and display its contents that are odd numbers on the screen. • This function should work with any of the following arrays of different sizes: int hours[3][9]; int stamps[7][9]; int cities[15][9]; • Write a demo program to show how to use the function show2D. this is c++ program Task 2: Array functions • Create a function called show2D. • This function should...

  • Write a program that calculates voltage from current and resistance values. Create three one-dimensional arrays named...

    Write a program that calculates voltage from current and resistance values. Create three one-dimensional arrays named current, resistance and voltage, each capable of holding 10 double-precision values. The values stored in current and resistance are as follows: current = 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98 resistance = 4.0, 8.5, 6.0, 7.35, 9.0, 15.3, 3.0, 5.4, 2.9, 4.8 Have your program pass these three arrays to a function called calcVolts() which calculates the elements in the voltage...

  • Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This...

    Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This will be the 3x3 matrix. Then, input 3, 64-bit, floating-point values. This will be a single-dimensional array and is the vector. Your program will simply ask the user to enter matrix values. Remember, there are 9 of these, but they need to be stored into a 3x3 multi-dimensional array (row-major). Then, your program will ask for the vector values, which will be stored into...

  • Write a java program that specifies three parallel one dimensional arrays name length, width, and area....

    Write a java program that specifies three parallel one dimensional arrays name length, width, and area. Each array should be capable of holding a number elements provided by user input. Using a for loop input values for length and width arrays. The entries in the area arrays should be the corresponding values in the length and width arrays (thus, area[i] =   length [i]* width [i]) after data has been entered display the following output: (in Java)

  • in C++ Write a program which uses the following arrays: empID: An array of 7 integers...

    in C++ Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary. The program...

  • need help with this python progam using numpy Create a 4x4 two dimensional array with numbers...

    need help with this python progam using numpy Create a 4x4 two dimensional array with numbers from 1 thru 16. show this then: Change the last element by dividing it in half. Show that the original array has changed. show this then: Set all values in row 2 to zero. Show the original array contains this change show this then: Set all values in column 1 to one. Shoe the original array contains this change. show this then: Display the...

  • create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array...

    create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array of doubles (call it scores) with three rows and three columns and that uses methods and loops as follows. Use a method containing a nested while loop to get the nine (3 x 3) doubles from the user at the command line. Use a method containing a nested for loop to compute the average of the doubles in each row. Use a method to...

  • Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student...

    Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X 5...

  • Q1) How would you declare an array of doubles called myDoubles? Arrays can be initialized in...

    Q1) How would you declare an array of doubles called myDoubles? Arrays can be initialized in one of two ways. In one method, the array elements are placed in a list enclosed in curly braces after the array name definition. For example, the code below creates an array of ints with 3 elements: 1, 2 and 3. int[] a = {1, 2, 3, 4}; We can also initialize an array with a new construct, indicating how many elements we want...

  • I should use the array and loop to create a java program according to the instruction,...

    I should use the array and loop to create a java program according to the instruction, but I have no idea how to do it. Introduction This lab assignment continues to give you practice using loops, particularly loops with variable termination conditions, and it also provides you an opportunity to use one-dimensional arrays. Recall that an array is used to store a collection of data. The data can be values of Java primitive data types or else objects (for instance,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT