Skip to content

Instantly share code, notes, and snippets.

@kjbrum
Last active May 8, 2018 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjbrum/dc60548d6d99d22234acc87ec4d2d61d to your computer and use it in GitHub Desktop.
Save kjbrum/dc60548d6d99d22234acc87ec4d2d61d to your computer and use it in GitHub Desktop.
Strip tags from an array
<?php
/**
* Strip tags from an array.
*
* @param array $arr The array to remove tags from
* @return array The new array without tags
*/
function r_strip_tags_array( $arr ) {
if( ! is_array( $arr ) ) return $arr;
$stripped_array = array();
foreach( $arr as $key => $val ) {
if ( is_array( $val ) ) {
$stripped_array[$key] = r_strip_tags_array( $val );
} else {
$stripped_array[$key] = trim( strip_tags( $val ) );
}
}
return $stripped_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment