HTMLPurifier::purifyArray PHP Method

purifyArray() public method

Filters an array of HTML snippets
public purifyArray ( string[] $array_of_html, HTMLPurifier_Config $config = null ) : string[]
$array_of_html string[] Array of html snippets
$config HTMLPurifier_Config Optional config object for this operation. See HTMLPurifier::purify() for more details.
return string[] Array of purified HTML
    public function purifyArray($array_of_html, $config = null)
    {
        $context_array = array();
        foreach ($array_of_html as $key => $html) {
            $array_of_html[$key] = $this->purify($html, $config);
            $context_array[$key] = $this->context;
        }
        $this->context = $context_array;
        return $array_of_html;
    }

Usage Example

Example #1
0
 /**
  * {@inheritDoc}
  */
 public function purifyArray($contents, $config = null)
 {
     if (!is_array($contents) && !$contents instanceof \Traversable) {
         throw new \BadMethodCallException('Argument 1 must be an array of strings');
     }
     if ($config && !$config instanceof ConfigurationInterface) {
         throw new \BadMethodCallException(sprintf('Argument 2 must be an instance of %s\\ConfigurationInterface or null', __NAMESPACE__));
     }
     return parent::purifyArray($contents, $config);
 }
All Usage Examples Of HTMLPurifier::purifyArray