I have recently upgraded to php 8.0 and a theme (admittedly old) I am using has a nested ternary which causes problems as it is deprecated. I have tried to unravel it but am stumped. Could someone help me figure out the proper parenthesis placements.
This is the code I am trying to 'upgrade'
$there_is_skills = 'yes';
(
! empty( $aboutus_feature1_title ) || ! empty( $aboutus_feature1_text ) ? $there_is_skills = 'yes' :
! empty( $aboutus_feature2_title ) || ! empty( $aboutus_feature2_text ) ? $there_is_skills = 'yes' :
! empty( $aboutus_feature3_title ) || ! empty( $aboutus_feature3_text ) ? $there_is_skills = 'yes' :
! empty( $aboutus_feature4_title ) || ! empty( $aboutus_feature4_text ) ? $there_is_skills = 'yes' :
$there_is_skills = '' );
Actually any code that will work - grin
Thanks!
CodePudding user response:
This can be turned into a single if
statement.
if (!empty($aboutus_feature1_title) || !empty($aboutus_feature1_text) ||
!empty($aboutus_feature2_title) || !empty($aboutus_feature2_text) ||
!empty($aboutus_feature3_title) || !empty($aboutus_feature3_text) ||
!empty($aboutus_feature4_title) || !empty($aboutus_feature4_text)) {
$there_is_skills = 'yes';
} else {
$there_is_skills = '';
}