Hi guys.
I'd like to return yellow or whatever the value of the key is if a match is found. Can I use the in_array" function? How can I do it?

$x = "BANANA";

function formatTitle($x){

    $titles = array ( 
                        "APPLE"    => "RED",
                        "BANANA "     => "YELLOW", 
                        "CARROT" => "ORANGE"                                     
                         );



           return $x;

}

    [man]array_key_exists[/man], if there's a chance [man]isset/man will miss it (see array_key_exists to see why that might happen).

      Hi guys. So how do I return the key value?

        array_search() returns the key for the array element that matches the supplied search value.

          Write a Reply...