// 40 characters string combine by 5 different fields
$field1 = apple;
$field2 = orange;
$field3 = pineapple;
$field4 = banana;
$field5 = strawberry;
// fields will be separated with a comma
$string = implode(", ", array_filter(array($field1, $field2, $field3, $field4, $field5)));
// string will be cut off at about 15th characters then make a break line
$stringList = explode("\n", wordwrap($string , 15));
// 1st rowField takes the 1st line of string
$rowField1 = array_shift($nutritionalList);
$string = implode(" ",$stringList );
$stringList = explode("\n", wordwrap($string , 25));
$rowField2 = "From 1st Row continued" . "\n" . implode("\n", $stringList) . "\n \n";}
This Output will show:
$rowField1 = "apple, orange"
$rowField2 = "From 1st Row continued \n pineapple, banana, strawberry"
However, my problem is if $field3, $field4, and $field5 are NULL, I don't want to display $rowField2 including the text "From 1st Row continued"
I tried IF/ELSE and ISSET procedure:
if (isset($stringList)) {
$rowField2 = "From 1st Row continued\n" . implode("\n", $stringList) . "\n\n";
}
else {
$rowField2 = NULL;
}
But $rowField2 still shows "From 1st Row continued". I want it not to display that if the last 3 fields are NULL.
$field1 = apple;rather than$field1 = "apple";? I don't see those constants defined.