最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

database - sanitize POST arrays

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

You 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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论