Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run $_POST array through a strip_tags() loop PHP

Tags:

arrays

post

php

Can I run the $_POST array through a loop to get the same result as the following code?

$_POST['manufacturer'] = strip_tags($_POST['manufacturer']);<br>
$_POST['part_no']      = strip_tags($_POST['part_no']);<br>
$_POST['product_name'] = strip_tags($_POST['product_name']);<br>
$_POST['link']         = strip_tags($_POST['link']);<br>

Or is there a way to apply strip_tags() to every field in the $_POST array?

like image 946
Kevin Avatar asked Mar 01 '26 13:03

Kevin


1 Answers

Yes, use array_map()

$_POST = array_map("strip_tags", $_POST);
like image 79
Ghilas BELHADJ Avatar answered Mar 03 '26 02:03

Ghilas BELHADJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!