Let's say I have array like this :
Array (
[2066] => Array (
[images_id] => 2066
[title] => title one)
[2063] => Array (
[images_id] => 2063
[title] => title two )
[2022] => Array (
[images_id] => 2022
[title] => title three )
)
or in database format like this:
a:3:{i:2066;a:2:{s:8:"image_id";s:4:"2066";s:5:"title";s:9:"Title One";}i:2063;a:2:{s:8:"image_id";s:4:"2063";s:5:"title";s:9:"Title Two";}i:2022;a:2:{s:8:"image_id";s:4:"2022";s:5:"title";s:11:"Title Three";}}
How to sanitize with esc_attr or sanitize_text_field for images_id and title ?
Any help really appreciated :)
You can sanitize the
images_id
and thetitle
fields of the array with Wordpress's esc_attr() and sanitize_text_field() functions using the PHP's array_walk() like below: