lundi 23 mars 2015

PHP different filters on specific array names

My form returns an array that allows for duplicate form names (that is working just fine).


I'm not sure where I go next with sanitizing each based on there names. I'm allowing the user to build the form dynamically and thus will have variables named like $_POST['tutorial[smallImage_1]'], $_POST['tutorial[smallImage_2]'], etc.. (as seen in my example array below).



if ($_POST['tutorial']) {

foreach ( $_POST['tutorial'] as $key=>$value ) {

if ($_POST['tutorial[code]'] {
$code = htmlentities($_POST['tutorial[code]']);
}

}
}



[tutorial] => Array
(
[1] => Array
(
[subtitle] => subtitle text
)

[2] => Array
(
[paragraph] => paragraph text
)

[3] => Array
(
[largeImage_1] => Array
(
[0] => image.png
)

)

[4] => Array
(
[smallImage_1] => Array
(
[0] => image.png
)

)

[5] => Array
(
[code] => code text
)

[6] => Array
(
[smallImage_2] => array
(
[0] => image.png
[1] => image.png
)
)

Aucun commentaire:

Enregistrer un commentaire