Having issues finding a way to display an ‘X’ in a table cell based on the whether or not one of the checkbox values is checked. Found the below solution on this forum, but it’s throwing the following error:
Warning: in_array() expects parameter 2 to be array, null given in /home/storm3/public_html/traffic/wp-content/themes/evoResponsive/single-projects.php on line 115
What am I missing here?
$crash = get_field('proj_crash');
echo '<table>';
echo '<tr>';
echo '<td>';
if(in_array('Timeliness', $crash )) { //this is line 115
echo 'X';
}
echo '</td>';
echo '<td>';
if(in_array('Accuracy', $crash )) { //same error generated here
echo 'X';
}
echo '</td>';
echo '</tr>';
echo '</table>';
BTW, I checked this thread, and a var dump returns ‘NULL’.
I don’t understand why a field with boxes checked would return NULL, nor why the solution that worked in the thread above does not work for me.
DOH! This is a repeater field, and this works:
`<?php
if(have_rows(‘project_areas’)):
while(have_rows(‘project_areas’)): the_row();
?>
<table>
<tr>
<td>Crash</td>
<td class=”align-center”>
<?php
if( get_sub_field(‘proj_crash’) ) {
if( in_array( ‘Timeliness’, get_sub_field(‘proj_crash’) ) )
{
echo ‘X’;
}}
?>
</td>
</tr>
</table>
<?php endwhile;
endif;
?>’