Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.