I have an array which outputs this when using var_dump:
array(3) {
["taxonomy"]=> string(10) "exam_board"
["terms"]=> array(1) {
[0]=> string(7) "pearson"
}
["field"]=> string(4) "slug"
}
pearsonarray(3) {
["taxonomy"]=> string(9) "exam_code"
["terms"]=> array(3) {
[0]=> string(4) "a123"
[1]=> string(4) "b123"
[2]=> string(4) "c123"
}
["field"]=> string(4) "slug"
}
a123array(3) {
["taxonomy"]=> string(10) "exam_level"
["terms"]=> array(1) {
[0]=> string(15) "pearson-a-level"
}
["field"]=> string(4) "slug"
}
The array is defined here:
$tax_query = array();
foreach ( get_object_taxonomies( 'exam' ) as $tax ) {
if ( isset( $_POST[ $tax ] ) ) {
$tax_query[] = array(
'taxonomy' => $tax,
'terms' => wp_unslash( ( array ) $_POST[ $tax ] ),
'field' => 'slug',
);
}
}
$args['tax_query'] = $tax_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args['paged'] = $paged;
$the_query = new WP_Query( $args );
What I'd like to do is loop through the array and output the terms into a table.
The table will need to look like this
<tr>
<td>pearson</td>
<td>a123</td>
<td>pearson-a-level</td>
</tr>
<tr>
<td>pearson</td>
<td>b123</td>
<td>pearson-a-level</td>
</tr>
<tr>
<td>pearson</td>
<td>c123</td>
<td>pearson-a-level</td>
</tr>
The loop I have so far returns all of the terms but I don't know how to get them individually, so I can use them in the table.
foreach ($tax_query as $key => $value) {
var_dump($value);
echo $value["terms"][0];
}