Assign values in foreach-loop: Problem solved

From: Date: Wed, 07 Sep 2005 17:35:35 +0000
Subject: Assign values in foreach-loop: Problem solved
Groups: php.general 
Request: Send a blank email to php-general+get-221981@lists.php.net to get a copy of this message
Thanks a lot for your fast answers, I'll do it like -TG and Jordan in his last post suggested! Sabine -------- Original-Nachricht -------- Betreff: [PHP] Assign values in foreach-loop Datum: Wed, 07 Sep 2005 19:14:40 +0200 Von: Sabine <phpdev@sric.de> Antwort an: phpdev@sric.de An: PHP general <php-general@lists.php.net> 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

« previous php.general (#221981) next »