Jump to content

Help with small PHP project


Awptics

Recommended Posts

Im a senior in highschool and my "server-scripting" professor gave me a project pertaining to HTML and PHP.

 

The project reads: Write a program that will take your first name and last name initials and create an asterisk printout of those letters on your screen.  The matrix is to be 16 by 16 for your letters.  Also modify the program to handle any letters input from the first 10 in the alphabet (A-J)

 

I have absolutely no clue what I'm doing and you guys seem like the right people to ask.  Any clues or help as how to do this?

Link to comment
https://forums.phpfreaks.com/topic/71428-help-with-small-php-project/
Share on other sites

I have a basic knowledge of PHP however I cannot get this to work, this is what I have been trying but he said something about an array and I have absolutely no clue what he is talking about.

 

<?php
$finitial=$_POST['finitial'];
$linitial=$_POST['linitial'];
if ($finitial=="a"){
echo "
     *       <br>
    * *     <br>
   *   *    <br>
  *****  <br>
 *        * <br>
*          *<br>
";}
if ($finitial=="b"){
echo "
*****  <br>
*        *<br>
*****  <br>
*        *<br>
*        *<br>
*****  <br>
";}
if ($finitial=="c"){
echo "
  ****  <br>
*        *<br>
*          <br>
*          <br>
*        *<br>
  ****  <br>
";}
if ($finitial=="d")
{
echo "
*****  <br>
*        *<br>
*        *<br>
*        *<br>
*        *<br>
*****  <br>
";
}
if ($finitial=="e")
{
echo "
*****  
*    
*****
*    
*    
*****
";
}
if ($finitial=="f")
{
echo "
*****
* 
*****
*
*
*
";
}
if ($finitial=="g")
{
echo "
****
*    *
*
*   ***
*    *
****
";
}
if ($finitial=="h")
{
echo "
*    *
*    *
******
*    *
*    *
*    *
";
}
if ($finitial=="i")
{
echo "
******
  **
**
**
**
******
";
}
if ($finitial=="j")
{
echo "
*****
*    *
*****
*    *
*    *
*****
";
}
?>
</font>

I have a basic knowledge of PHP however I cannot get this to work, this is what I have been trying but he said something about an array and I have absolutely no clue what he is talking about.

 

To give you an idea of what he's talking about.

 

<?php

$numbers = Array();

$numbers[0] = "zero";
$numbers[1] = "one";
$numbers[2] = "two";
//etc

//this loop counts from zero to nine in actual words
for($i = 0; $i < 10; $i++)
{
  echo "$numbers[$i]<br />";
}
?>

 

This type of trick is fairly common, and applies to any programming language, so I don't feel like I'm doing your homework for you.  Much.

 

No messy if statements.  If you were going to use if statements like that, you'd be much better off using a switch statement.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.