Jump to content


Photo

PHP code help


  • Please log in to reply
5 replies to this topic

#1 matthew61773

matthew61773
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 23 August 2006 - 04:06 PM

Hi
I am doing a question in college and need some simple code in PHP.

I have to Write a PHP script that outputs your name to the screen 5 times, each time the font size increasing by 2.

Any ideas?

thanks :)

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 23 August 2006 - 04:06 PM

How do you get the name?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 matthew61773

matthew61773
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 23 August 2006 - 04:09 PM

my own name or a name typed into the code.

#4 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 23 August 2006 - 04:10 PM

There's a million ways to do this but....

$myName = "Phil P";
$fs = "10";

print "<ul>";
for ($i = 0; $i <= 4; $i++) {
	print "<li style='font-size:".$fs."px'>".$myName."</li>";
	$fs = $fs+2;
}
print "</ul>";

call me a safe bet, i'm betting i'm not

#5 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 23 August 2006 - 04:11 PM

<?php
$name="matthew61773";
$font=10;
$i=0;
while($i<5){
echo('<font size="'.$font+($i*2).'">'.$name.'</font><br>');
$i++;
}
?>

Orio.
Think you're smarty?

(Gone until 20 to November)

#6 matthew61773

matthew61773
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 23 August 2006 - 04:17 PM

Thanks guys much appreciated
;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users