Re: Array question

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

 



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@xxxxxxxxxxxxxx> 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!)

--
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