perl to php code change?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deras
Forum Newbie
Posts: 24
Joined: Sun Nov 02, 2003 10:26 am

perl to php code change?

Post by deras »

i am moving a script from perl to php and i the following array does not work in the new php version. what do i need to change to get it to work?

Code: Select all

@x=($m1,$m2,$m3);
$n=1;
foreach $v(@x){
$var="md".$n;
if($v > 90 ){$$var ="||||||||||||||||||||||";}
elsif($v >80 ){$$var ="||||||||||||||||||||";}
elsif($v > 70 ){$$var ="||||||||||||||||||";}
elsif($v > 60 ){$$var ="||||||||||||||||";}
elsif($v > 50 ){$$var ="||||||||||||||";}
elsif($v > 40 ){$$var ="||||||||||||";}
elsif($v > 30 ){$$var ="||||||||||";}
elsif($v > 20 ){$$var ="||||||";}
elsif($v > 10 ){$$var ="||||";}
elsif($v > 0 ){$$var ="||";}
$n++;
  }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$x = array($m1, $m2, $m3);
$n = 1;
foreach($x as $v)
{
  $var = 'md' . $n;
  if($v > 90 ){$$var ="||||||||||||||||||||||";}
elsif($v >80 ){$$var ="||||||||||||||||||||";}
elsif($v > 70 ){$$var ="||||||||||||||||||";}
elsif($v > 60 ){$$var ="||||||||||||||||";}
elsif($v > 50 ){$$var ="||||||||||||||";}
elsif($v > 40 ){$$var ="||||||||||||";}
elsif($v > 30 ){$$var ="||||||||||";}
elsif($v > 20 ){$$var ="||||||";}
elsif($v > 10 ){$$var ="||||";}
elsif($v > 0 ){$$var ="||";}
$n++;
  }
I think.. it's been a while since I worked in perl..
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

$$var ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

AGISB wrote:$$var ?
variable variables: http://www.php.net/manual/en/language.v ... riable.php
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

But in Perl that is a Perl Process ID Variable so I guess there is your possible error
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

true.. but he did say he's moving stuff over from perl to php.. so I take the code as half perl, half php. :)
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

So I guess we need more input of what this code is supposed to do and what is does at the moment ;)
deras
Forum Newbie
Posts: 24
Joined: Sun Nov 02, 2003 10:26 am

Post by deras »

what i posted was 100% perl code
Post Reply