admin管理员组文章数量:1389799
I'm trying to sanitize some arrays received through $_POST[] and insert them into database. How should I do that?
The html is name="room_types[]"
$room_types = $_POST['room_types'];
how to sanitize this array?
I'm trying to sanitize some arrays received through $_POST[] and insert them into database. How should I do that?
The html is name="room_types[]"
$room_types = $_POST['room_types'];
how to sanitize this array?
Share Improve this question asked Feb 18, 2020 at 7:39 dragos.nicolaedragos.nicolae 134 bronze badges1 Answer
Reset to default 0You can use array_map
like this:
$room_types = isset( $_POST['room_types'] ) ? (array) $_POST['room_types'] : array();
$room_types = array_map( 'esc_attr', $room_types ); // Replace esc_attr with your desire sanitization
本文标签: databasesanitize POST arrays
版权声明:本文标题:database - sanitize POST arrays 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744739757a2622539.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论