![]() |
PHP: Kleine Unstimmigkeit mit foreach()
Moin allerseits,
ich hab ein kleines Problem mit foreach. Ich hab z.Zt. folgendes Array:
Code:
Ueber dieses array laufe ich z.Zt. so drueber:
$forum_auth_ary = array(
'auth_view' => $row['auth_view'], 'auth_read' => $row['auth_read'], 'auth_post' => $row['auth_post'], 'auth_reply' => $row['auth_reply'], 'auth_edit' => $row['auth_edit'], 'auth_delete' => $row['auth_delete'], 'auth_sticky' => $row['auth_sticky'], 'auth_announce' => $row['auth_announce'], 'auth_vote' => $row['auth_vote'], 'auth_pollcreate' => $row['auth_pollcreate'], 'auth_attachments' => $row['auth_attachments'], 'auth_download' => $row['auth_download'] );
Code:
Die erste Zeile stoert mich da ein bisschen. Ich wuerde den neuen Wert gerne in $value schreiben, so dass er nachher auch im array gespeichert ist.
foreach ($forum_auth_ary as $name => $value)
{ $forum_auth_ary[$name] = (isset($_POST[$name])) ? intval($_POST[$name]) : $forum_auth_ary[$name]; $varname = 'S_'. strtoupper($name); $template->assign_var($varname, create_select($select_items, $forum_auth_ary[$name], True, $name)); } Folgendes laesst PHP aber nicht zu:
Code:
Hat jemand eine Idee? Notfalls kann ich auch uebers array arbeiten, allerdings waers ueber $value ein bisschen schoener ;)
foreach ($forum_auth_ary as $name => &$value)
Greetz alcaeus |
Re: PHP: Kleine Unstimmigkeit mit foreach()
Das geht IMHO nicht, da foreach keine Referenz auf das Array liefert, sondern den Wert einfach per Zuweisung an $value gibt.
|
Re: PHP: Kleine Unstimmigkeit mit foreach()
das funktioniert leider erst seit PHP5 ;)
(also das mit foreach ($array as $name => &$value) {} ) aenogym |
Re: PHP: Kleine Unstimmigkeit mit foreach()
Ok, nachdem das Ding ja auch noch auf PHP4 laufen soll, faellt die Loesung leider weg. Danke trotzdem :)
Greetz alcaeus |
Re: PHP: Kleine Unstimmigkeit mit foreach()
Zitat:
![]() |
Re: PHP: Kleine Unstimmigkeit mit foreach()
Zitat:
Zitat:
Dass mir das nicht aufgefallen ist als ich die Hilfe studiert habe :wall: Greetz alcaeus |
Re: PHP: Kleine Unstimmigkeit mit foreach()
Ach .... ja ..... wer lesen kann ist klar im Vorteil. Sorry. :duck:
Als Entschuldigung hab ich gleich mal für dich gevotet. :) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:48 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz