this is what my code looks like: Any help will be very appreciable.
<?php
$btn = get_field('line_btn');
if( $btn && in_array('study', $btn ) ) {
echo 'study'; // working well
}
elseif( $btn && in_array('help', $btn ) ) {
echo 'help'; // working well
}
elseif( $btn && in_array('study', 'help', $btn) ) {
echo 'both selected'; // not working
}
?>
in_array()
only checks for one value in the array and you are trying to pass in two. You would have to us two separate in_array()
functions in the elseif
.
<?php
$btn = get_field('line_btn');
if( $btn && in_array('study', $btn ) ) {
echo 'study'; // working well
}
elseif( $btn && in_array('help', $btn ) ) {
echo 'help'; // working well
}
elseif( $btn && in_array('study', $btn) && in_array( 'help', $btn ) {
echo 'both selected';
}
?>