Kevin.a Kevin.a - 3 months ago 27
PHP Question

Matching a string with an array key

I'm trying how to figure something out for my website.
This is not my code just an example to make it easier to understand what i mean.

Lets say i have an array like this:

$services = array(
Marketing => marketing:342343423423,
Sales => sales:779876786,

And i have a form on my website. I can get the posted values with a POST request.

The POST request can for example look like this


Now what i want to know is how to do the next:

matches one of the array keys inside
then print the relevant value of this array key.

So lets say an user fills my form, and his service request is marketing then i want to check if this service request exists inside the
variable and if it exist print the value.


use key_exists function of php.

   //exists, perform rest of the logic here.