Question

In: Computer Science

Suppose we have an array as follow: var $fruits =new Array(“banana”, “strawberry”, “papaya”, “melon”); Write a...

Suppose we have an array as follow: var $fruits =new Array(“banana”, “strawberry”, “papaya”, “melon”); Write a PHP script which will display the list of fruits in the browser as below: • Fruit 1: banana • Fruit 2: strawberry • Fruit 3: papaya

Solutions

Expert Solution

PHP script :

<!DOCTYPE html>

<html lang="en">

    <head>

        <!-- title for web page -->

        <title>PHP Array</title>

        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1">

       

    </head>

    <body>

    <?php

    //declaring PHP array

    $fruits=Array("banana", "strawberry", "papaya", "melon");

    //using for loop

    for($i=0;$i<count($fruits);$i++)

    {

        //print each array elements

        echo "<li>Fruit ".($i+1).":".$fruits[$i]."</li>";

    }

?>

    </body>

</html>

=======================================

Output :


Related Solutions

There are 10 ice creams. There are strawberry, coconut, matcha, and melon flavor. Suppose that each ice cream of the same flavor is indistinguishable from another.
  There are 10 ice creams. There are strawberry, coconut, matcha, and melon flavor. Suppose that each ice cream of the same flavor is indistinguishable from another. a. How many combinations are there such that there is at least 2 strawberry and at most 2 coconut ice cream? b. How many combinations are there such that there is at least 2 strawberry, at most 2 coconut ice cream, and at least 1 matcha if someone 3 ice creams. (Hint: There...
. Suppose that banana prices at supermarkets in a particular large metropolitan area follow a normaldistribution...
. Suppose that banana prices at supermarkets in a particular large metropolitan area follow a normaldistribution with mean µ= 58.6 cents per pound and standard deviation σ= 4.3 cents per pound. For parts (a) through (c), what is the probability that the price of bananas at a random supermarket will be: (a)  below 55 cents per pound? (b)  above 65 cents per pound?   (c)  Between 57 and 62 cents per pound? (d) Below 57 cents or above 62 cents per pound? (d)  What is...
Suppose that we back-test a VaR model using 300 days of data. The VaR confidence level...
Suppose that we back-test a VaR model using 300 days of data. The VaR confidence level is 99% and we observe 10 exceptions. Do we reject the model?
Suppose we have an array A that contains a prime numbers from 2 to 200 in...
Suppose we have an array A that contains a prime numbers from 2 to 200 in sorted order. How many items of the array A would the binary search algorithm have to examine before concluding that 60 is not in the array A? 30 200 100 6 2- Suppose we have an array that contains 182 village name. These names are sorted alphabetically. How many names would binary search algorithm examine to locate a particular name in the array, in...
We have an array A of size n. There are only positive integers in this array....
We have an array A of size n. There are only positive integers in this array. Note that the array may have integers that are not distinct, and it could be any array of positive integers in creation (I like the numbers found the decimal expansion of π for instance). When possible provide the exact complexity of the algorithm. If it’s not possible explain the O/Ω/Θ complexity. a. Design an efficient algorithm to find the maximum difference between any two...
We have an array A of size n. There are only positive integers in this array....
We have an array A of size n. There are only positive integers in this array. Note that the array may have integers that are not distinct, and it could be any array of positive integers in creation (I like the numbers found the decimal expansion of π for instance). When possible provide the exact complexity of the algorithm. If it’s not possible explain the O/Ω/Θ complexity. a. Design an efficient algorithm to find the maximum difference between any two...
Find the second minimum of an integer array? //this is the template we follow. Answer must...
Find the second minimum of an integer array? //this is the template we follow. Answer must run in linear time (i.e. no nested loops). package findsecondminimumtest; import java.util.Arrays; import java.util.NoSuchElementException; public class FindSecondMinimumTest { /** * Find the second minimum of an integer array * * @param a is the array * @return the second minimum if array has at least two elements and it * indeed has a second minimum. If array length is less than two, it throws...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6};...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6}; and we also have a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6, where 1 is the first in the linked list L, followed by 2 etc. We want to put a new item 4 between 3 and 5 in the array a and in the linked list L (a) Explain in plain English how you do...
Suppose that all the numbers in an array are located in an interval [0,12], and we...
Suppose that all the numbers in an array are located in an interval [0,12], and we need to find the largest element with accuracy ε = 0.8. How many iterations will you need if we use the quantum optimization algorithm? How many times do we need to apply Grover's algorithm? Trace the quantum optimization algorithm for the case when the actual largest element is a5 = 3.14
a. You have to write the steps that we need to insert a new node as...
a. You have to write the steps that we need to insert a new node as the head of an existing linked list. b.You have to write the code in c++ programming language of the function that we need to insert a new node in the end of an existing node. c.Suppose that the below main function is executed correctly and all the functions that are invoked are imported from functions.h file. Explain. int main(){ Node *head=NULL; insertEnd(&head,"John");//inserts a new...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT