3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $copy = $columns = [ // in groups of 8 for simpler counting/reading 'naam', 'geslacht', 'fokrichting', 'kleur', 'kleur_uk', 'geb_dat2', 'fokker', 'fok_plaats', 'prijs', 'film_url', 'volgnr', 'jaar', 'extra', 'extra_uk', 'topstar', 'horsetelex_pedigree_id', 'sb_m_horsetelex_pedigree_id', 'kwpn_pedigree_id', 'sb_v', 'sb_vv', 'sb_vvv', 'sb_m', 'sb_vm', 'sb_vvm', 'sb_mm', 'sb_vmm', 'sb_vmv', 'sb_mmm', 'sb_mv', 'sb_mvv', 'sb_mmv', 'sb_mvm', 'sb_vvvv', 'sb_mvvv', 'sb_vmvv', 'sb_mmvv', 'sb_vvmv', 'sb_mvmv', 'sb_vmmv', 'sb_mmmv', 'sb_vvvm', 'sb_mvvm', 'sb_vmvm', 'sb_mmvm', 'sb_vvmm', 'sb_mvmm', 'sb_vmmm', 'sb_mmmm' ]; $column_count = sizeof($columns); sort($copy); $_POST = array_combine($copy, range(1, $column_count)); array_splice($_POST, 0, 4); // remove the first four elements as demonstration var_export($_POST); echo "\n"; $defaults = array_fill_keys($columns, null); $POST_filtered = array_intersect_key($_POST, $defaults); var_export($POST_filtered); echo "\n"; $clean_data = array_replace($defaults, $POST_filtered); var_export($clean_data); echo "\n";
based on KrUhV
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0alpha1
array ( 'fokker' => 5, 'fokrichting' => 6, 'geb_dat2' => 7, 'geslacht' => 8, 'horsetelex_pedigree_id' => 9, 'jaar' => 10, 'kleur' => 11, 'kleur_uk' => 12, 'kwpn_pedigree_id' => 13, 'naam' => 14, 'prijs' => 15, 'sb_m' => 16, 'sb_m_horsetelex_pedigree_id' => 17, 'sb_mm' => 18, 'sb_mmm' => 19, 'sb_mmmm' => 20, 'sb_mmmv' => 21, 'sb_mmv' => 22, 'sb_mmvm' => 23, 'sb_mmvv' => 24, 'sb_mv' => 25, 'sb_mvm' => 26, 'sb_mvmm' => 27, 'sb_mvmv' => 28, 'sb_mvv' => 29, 'sb_mvvm' => 30, 'sb_mvvv' => 31, 'sb_v' => 32, 'sb_vm' => 33, 'sb_vmm' => 34, 'sb_vmmm' => 35, 'sb_vmmv' => 36, 'sb_vmv' => 37, 'sb_vmvm' => 38, 'sb_vmvv' => 39, 'sb_vv' => 40, 'sb_vvm' => 41, 'sb_vvmm' => 42, 'sb_vvmv' => 43, 'sb_vvv' => 44, 'sb_vvvm' => 45, 'sb_vvvv' => 46, 'topstar' => 47, 'volgnr' => 48, ) array ( 'fokker' => 5, 'fokrichting' => 6, 'geb_dat2' => 7, 'geslacht' => 8, 'horsetelex_pedigree_id' => 9, 'jaar' => 10, 'kleur' => 11, 'kleur_uk' => 12, 'kwpn_pedigree_id' => 13, 'naam' => 14, 'prijs' => 15, 'sb_m' => 16, 'sb_m_horsetelex_pedigree_id' => 17, 'sb_mm' => 18, 'sb_mmm' => 19, 'sb_mmmm' => 20, 'sb_mmmv' => 21, 'sb_mmv' => 22, 'sb_mmvm' => 23, 'sb_mmvv' => 24, 'sb_mv' => 25, 'sb_mvm' => 26, 'sb_mvmm' => 27, 'sb_mvmv' => 28, 'sb_mvv' => 29, 'sb_mvvm' => 30, 'sb_mvvv' => 31, 'sb_v' => 32, 'sb_vm' => 33, 'sb_vmm' => 34, 'sb_vmmm' => 35, 'sb_vmmv' => 36, 'sb_vmv' => 37, 'sb_vmvm' => 38, 'sb_vmvv' => 39, 'sb_vv' => 40, 'sb_vvm' => 41, 'sb_vvmm' => 42, 'sb_vvmv' => 43, 'sb_vvv' => 44, 'sb_vvvm' => 45, 'sb_vvvv' => 46, 'topstar' => 47, 'volgnr' => 48, ) array ( 'naam' => 14, 'geslacht' => 8, 'fokrichting' => 6, 'kleur' => 11, 'kleur_uk' => 12, 'geb_dat2' => 7, 'fokker' => 5, 'fok_plaats' => NULL, 'prijs' => 15, 'film_url' => NULL, 'volgnr' => 48, 'jaar' => 10, 'extra' => NULL, 'extra_uk' => NULL, 'topstar' => 47, 'horsetelex_pedigree_id' => 9, 'sb_m_horsetelex_pedigree_id' => 17, 'kwpn_pedigree_id' => 13, 'sb_v' => 32, 'sb_vv' => 40, 'sb_vvv' => 44, 'sb_m' => 16, 'sb_vm' => 33, 'sb_vvm' => 41, 'sb_mm' => 18, 'sb_vmm' => 34, 'sb_vmv' => 37, 'sb_mmm' => 19, 'sb_mv' => 25, 'sb_mvv' => 29, 'sb_mmv' => 22, 'sb_mvm' => 26, 'sb_vvvv' => 46, 'sb_mvvv' => 31, 'sb_vmvv' => 39, 'sb_mmvv' => 24, 'sb_vvmv' => 43, 'sb_mvmv' => 28, 'sb_vmmv' => 36, 'sb_mmmv' => 21, 'sb_vvvm' => 45, 'sb_mvvm' => 30, 'sb_vmvm' => 38, 'sb_mmvm' => 23, 'sb_vvmm' => 42, 'sb_mvmm' => 27, 'sb_vmmm' => 35, 'sb_mmmm' => 20, )