You are here: Re: how to save/restore current array position? « PHP Programming Language « IT news, forums, messages
Re: how to save/restore current array position?

Posted by Shelly on 07/24/05 18:12

"Magnus Warker" <wagner@abwesend.de> wrote in message
news:dc09ge$j4l$00$1@news.t-online.com...
> Hi Shelly,
>
> thank you very much!
>
>> C style:
>> (1) Set a session variable with the value and read the value.
>> (2) Pass the variable to the next page and use $_GET
>
> Which variable are you talking about? There is no "next page". The problem
> code is executed at once.

OK, that is simpler. Here is a suggestion. Set a hidden variable as
"the_index" with a value equal to zero. Then as your index changes, set the
value of the_index to that value. Now you begin the loop at the value of
the_index with a pre-test.

$pos = $POST['the_index'] or $pos = $the_index. (I'm not sure which)
while (blah) do {
}

>
>> OO style:
>> encapsulate in the class as a variable in the class. The obect then
>> has
>> the value of "pos", and getpos and setpos are merely accessor and mutator
>> methods of the class.
>
> I think I cannot follow. Even when encapsulating the array in an
> additional
> class, the original problem still remains.
>
> What I already tried is to just do the while on a copy of the array, but
> copying resets the position.

class theDef {
var pos;
}

$theObj = new theObj();
$i = $theObj->getpos();

while (blah) do {
stuff
$i++;
theObj->setpos($i);
}


Shelly

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация