Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP - Sanitize a multidimensional array
<?php
/**
* Sanitize a multidimensional array
*
* @uses htmlspecialchars
*
* @param (array)
* @return (array) the sanitized array
*/
function purica_array ($data = array()) {
if (!is_array($data) || !count($data)) {
return array();
}
foreach ($data as $k => $v) {
if (!is_array($v) && !is_object($v)) {
$data[$k] = htmlspecialchars(trim($v));
}
if (is_array($v)) {
$data[$k] = purica_array($v);
}
}
return $data;
}
@hieronymusdesign

This comment has been minimized.

Copy link

@hieronymusdesign hieronymusdesign commented Sep 24, 2015

Thanks, mind if i take this. Was looking for it ;)

Regards Jerome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment