A) Create an associative array called cars. The array should hold information about some cars. Each array key represents the car registration number and its associative value contains a numeric array of size 4 that holds car model name, mileage, number of accidents and car colour respectively. [Create at least 10 cars information in the array]

B) Write PHP program that read the array and display the following:
1. Display all cars’ information using HTML table with headers titled Registration, Model, Mileage and Accidents. Highlight each row by the car colour.
2. Find and display the average mileage for all cars with no accidents.
Appropriate messages should be displayed in case there is no output

Recommended Answers

All 4 Replies

How I would respond in such question? “ Move to OOP , you are describing an object , and you keep its properties in an associative array that could be anything or nothing”. OOP isn't the greatest thing can be , but is the greater we have so far.

People need to recognize that PHP is an object-oriented language (C++ with training wheels) that runs on a web server, and can emit HTML and javascript as necessary to run on the client (browser) for further processing. I posted an article here about how to do that properly. Read it. It may help you build better web sites!

I still prefer "Do your own effing homework"
to all the above

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.