Skip to content

array_esc_attr

Tonya Mork edited this page Mar 12, 2017 · 1 revision

The array_esc_attr() function escapes the HTML attributes for each element's string value by passing each one through the WordPress esc_attr.

Escaping means the following characters are encoded: < (less than), > (greater than), & (ampersand), " (double quote), and ' (single quote).

You can escape one level of the array, or for deeper arrays, you can set the second argument to true.

Syntax

array array_esc_attr( 
     array &$subjectArray, 
     [ bool $goDeep = false ]
);

Where:

$subjectArray is the array to work on and contains the subset you want

$goDeep when true, this function will escape all string values at each level within the subject array; else, only the first depth level is escaped.

When to Use

Use this function when you need to clean up an array of attributes before rendering out to the browser or storing in the database.


« Back to Array API

Clone this wiki locally