You are here: array inverting itself « PHP Programming Language « IT news, forums, messages
array inverting itself

Posted by GarryJones on 10/23/07 20:57

I have a list of names from some are selected to be displayed on a
form. In this form I create an array of all the displayed values. The
user can select one of them.

Note that only some of the possible names are displayed on the form.

I then want to check that the name the user selects is in the array.

I want to refer to the array on the page the "post" form is pointing
to. So I put the array in a session

$_SESSION['arr_motakt'] = $arr_motakt;

I test here with
print_r (array_values($_SESSION['arr_motakt']));

Which prints my values correctly.

At the top of the page the "post" form points to I have this row again
after starting the session

print_r (array_values($_SESSION['arr_motakt']));

But now it prints an inverted selection of the names, ie the ones that
were not displayed on the form.


Further explanation.
My original list
1 Anna
2 Bertil
3 Conny
4 David
5 Ethel
6 Frank
7 Gertrud
8 Harald

Names displayed on form and shoved into array.
1 Anna
5 Ethel
7 Gertrud

The user can choose 1 or 5 or 7.

When I test the array it prints correctly
1 Anna
5 Ethel
7 Gertrud

The form is posted to the next page.

I test the array on line 2 after starting session and now it says.

2 Bertil
3 Conny
4 David
6 Frank
8 Harald

There is no further code between the form page and the page I post to.

How have I managed to invert the array?

Garry Jones
Sweden

 

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

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