Skip to content

Commit 41bb025

Browse files
committed
✨ add the filter_fields() function
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 8c0eb01 commit 41bb025

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

CodeIgniter/Framework/helpers/form_helper.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,23 @@ function form_error($field = '', $prefix = '', $suffix = '')
906906
}
907907
}
908908

909+
// ------------------------------------------------------------------------
910+
911+
if ( ! function_exists('filter_fields'))
912+
{
913+
914+
/**
915+
* Filter Unknown Form Fields Out
916+
*
917+
* @param array $fields
918+
* @param array $expected_fields
919+
* @return array
920+
*/
921+
function filter_fields($fields = [], $expected_fields = [])
922+
{
923+
return array_intersect_key($fields, array_flip($expected_fields));
924+
}
925+
}
909926

910927
// ------------------------------------------------------------------------
911928

0 commit comments

Comments
 (0)