Write a php program to read the employee details
Answers
please mark brainlist
Answer:
Here is an example of a PHP program that reads in employee details and stores them in an array:
<?php
$employee_details = array();
$num_employees = readline("Enter the number of employees: ");
for ($i = 0; $i < $num_employees; $i++) {
$name = readline("Enter the name of employee " . ($i + 1) . ": ");
$age = readline("Enter the age of employee " . ($i + 1) . ": ");
$salary = readline("Enter the salary of employee " . ($i + 1) . ": ");
$employee_details[$i] = array(
'name' => $name,
'age' => $age,
'salary' => $salary
);
}
print_r($employee_details);
?>
Explanation:
This program begins by initializing an empty array called $employee_details. It then prompts the user to enter the number of employees using the readline() function, which reads a line of input from the user. A for loop is then used to iterate through the number of employees. For each employee, the program prompts the user to enter their name, age, and salary, and then stores this information in the $employee_details array. The information is stored in sub-array with the keys 'name', 'age', 'salary' respectively. Finally, the program uses the print_r() function to print the $employee_details array, displaying the employee details that were entered.
This is just one example of how you could read in employee details using PHP. There are many other ways to achieve this, such as using a form to collect the information, or reading the information from a file or database.
Note: readline() is not a built in function in php, it could be replaced with fgets(STDIN) or readline() if you use the readline extension.
More question and answers:
https://brainly.in/question/54832243
https://brainly.in/question/16296430
#SPJ3