Assign values in foreach-loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello to all,

is it possible to assign values to the array for which I do the foreach-loop?

foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
       if ($arr1['id'] == $arr2['id']) {
           $arr1['selected'] = true;
       }
} }

I think $arr1 is only a temp-var, so the assignment won't reflect on $_SESSION['arr1'] . Is that right? Surely I can do it with a for-loop, but those arrays are a bit complex and a foreach would be much easier to read.

Thanks in advance for your answers
Sabine

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux