Perform Function on Each Item of an Array

Avatar of Chris Coyier
Chris Coyier on

array_map() takes two arguments. The first argument is the function to perform on the second argument (which is an array). Returns a new array.

$original = array('<p>Paragraph</p>', '<strong>Bold</strong>');
$new = array_map('strip_tags', $original);

// $new is now array('Paragraph', 'Bold');