What are the precise rules/PHP function for encoding strings into POST arrays?
Greetings,

Just getting into PHP web development.  I've got an HTML form where a user checks some series of dynamically-generated checkboxes, and submits via POST.  On the PHP side, I want to check which of the check-boxes were clicked.

I have an array $full_list, and am doing something like

    $selected_checkboxes = array_filter($full_list, function($item) {
        array_key_exists($item, $_POST);
      }

I run into problems when a list item is named, for example "Peanut Butter", since in the POST array it is named "Peanut_Butter".  

I could certainly just str_replace " " with "_" before checking array_key_exists, but I imagine that there is a more fundamental encoding problem here; specifically, I'm not sure of exactly what layer transforms normal strings in HTML Forms (value="Peanut Butter") into "Peanut_Butter".  

So: 

 - what layer is responsible for this conversion? Is it the browser?  
 - what are the exact conversion rules, and is there a PHP function out there that will replicate that exact conversion?

Thanks!
What are the precise rules/PHP function for encoding strings into POST arrays?
===

Greetings,

Just getting into PHP web development.  I've got an HTML form where a user checks some series of dynamically-generated checkboxes, and submits via POST.  On the PHP side, I want to check which of the check-boxes were clicked.

I have an array $full_list, and am doing something like

    $selected_checkboxes = array_filter($full_list, function($item) {
        array_key_exists($item, $_POST);
      }

I run into problems when a list item is named, for example "Peanut Butter", since in the POST array it is named "Peanut_Butter".  

I could certainly just str_replace " " with "_" before checking array_key_exists, but I imagine that there is a more fundamental encoding problem here; specifically, I'm not sure of exactly what layer transforms normal strings in HTML Forms (value="Peanut Butter") into "Peanut_Butter".  

So: 

 - what layer is responsible for this conversion? Is it the browser?  
 - what are the exact conversion rules, and is there a PHP function out there that will replicate that exact conversion?

Thanks!