Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PHP Create an array with 3-4 people\'s information (first name, last name, phone

ID: 3682759 • Letter: P

Question

PHP

Create an array with 3-4 people's information (first name, last name, phone). Create a username by combining first initial of first name, first 3 letters of last name, and last 4 numbers of phone. Display the information from the array and the username on the web page in a table or whatever format you want to use.

So, you don't really need a form. However, if you want to do something more challenging, create a form that captures a person's info, then add it to the array on the next page (you could save it to a text file and have the text file dump into an array).

Explanation / Answer

<html>
<body>
<?php
$name = array('aaa','bbb','ccc');
$last=array('zzz','xxx','yyy');
$num=array(2345,3456,7895);


printf("%s%s%d ", $name[0], $last[0],$num[0]);
printf("%s%s%d ", $name[1], $last[1],$num[1]);
printf("%s%s%d ", $name[2], $last[2],$num[2]);

?>