Gossamer Forum
Home : General : Internet Technologies :

Re: [Michael_Bray] Simple PHP problem I'm stuck on.

Quote Reply
Re: [Michael_Bray] Simple PHP problem I'm stuck on. In reply to
I’ve got it close but can’t figure it out. I have done:

Code:
<?php

$i = 1
;
$direction = "up"
;
$v = 5
;

$loop = 20
;
$l = 1
;

while ($l < $loop
)
{
if($direction == "up"
)
{
$l
++;
print $i
;
$i
++;
if ($i == $v)
{
$direction = "down"
;
}
} else
{
$l
++;
print $i
;
$i = $i-1
;
if ($i == 1)
{
$direction = "up"
;
}
}
}



?>

But it outputs 1,2,3,4,5,4,3,2,1,2,3,4,5,4 etc
When I need the last numbers to repeat next to each other i.e. 1,2,3,4,5,5,4,3,2,1,1,2,3,4,5
Cheers,
Michael Bray
Subject Author Views Date
Thread Simple PHP problem I'm stuck on. Michael_Bray 9687 May 8, 2011, 9:04 PM
Thread Re: [Michael_Bray] Simple PHP problem I'm stuck on.
Michael_Bray 9334 May 8, 2011, 9:25 PM
Post Re: [Michael_Bray] Simple PHP problem I'm stuck on.
Michael_Bray 9289 May 8, 2011, 10:27 PM