Re: foreach questions

From: Date: Tue, 01 Jan 2008 20:05:31 +0000
Subject: Re: foreach questions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-266454@lists.php.net to get a copy of this message
On Jan 1, 2008, at 11:59 AM, Martin Jerga wrote:
Hello, the problem is in this part of code $key -> $value This notation means that you are trying to access property $value on the object $key. Just replace it with $key => $value and you will get the result as expected. Martin J
Thank you for the response; I should have known. I don't use this type of loop often enough to get it straight the first time. Jeff K
jekillen wrote / napísal(a):
Hello; I have this section of code: @include('tmp_index.php'); foreach($index as $key -> $value)
          {
           if($input == $key)
             {
              $target_file = $value;
             }
          }
And I am getting this error: Fatal error: Cannot access empty property in <path>/confirmation.php on line 131 Several questions: How long can an index be in an associative array? (the indexes I use in this array are 32 character hashes) Can it start with a number (since a hash can start with a number) Can I use $index as an array name? (I do not remember off hand what the reserved key words are) I am not sure what the "empty property" is that it is referring to. Thank you in advance for info; Jeff K


« previous php.general (#266454) next »