Re: Array question

From: Date: Tue, 27 Feb 2007 14:49:39 +0000
Subject: Re: Array question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-249500@lists.php.net to get a copy of this message
Mike, See entire function under topic "Array question - maybe UTF?"... I am trying to change accented characters to their equivalent without accents. And yes, the arrays look fine after var_dump()... Gerry On 2/27/07, Ford, Mike <M.Ford@leedsmet.ac.uk> wrote:
On 27 February 2007 04:23, Gerry D wrote: I have a question on how to retrieve the value that corresponds to a key in an array. $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');
              $key = array_search($c, $fruit);
              if ( $key === FALSE )
                      $n = $c;
              else
              {
                      $n = $fruit[$key];  // how to get the value???
              }
the array_search works ok, but how do I get the value? all I get back is 'a' or 'b', not 'apple' or 'banana'... Please show a little more code, as it looks to me as though this should work how you think it should. Specifically: how do we know what is in $c? how do you know the array_search works? how do you know $n is only getting 'a', 'b', or 'c'? (Hint: var_dump() is your friend!)


« previous php.general (#249500) next »