0

The loop outputs the values ​​of the array and inserts the block classes from the $blocks array. Why can not i put a ternary operator between the strings?

$Values = [
"name"     =>  "Name", 
"age"      =>  "Age",
"from"     =>  "From",
"colors"   =>  ["Blue", "White", "Yellow"],      
"lessons"  =>  ["Maths", "Physics", "English"],
"comment"  =>  "Comment",     
];

$blocks =[
"name"     =>  'user',  
"age"      =>  'age',
"from"     =>  'from', 
"colors"   =>  'colors',        
"lessons"  =>  'lessons',
"comment"  =>  'comment',     
];
 
 
foreach($Values as $key => $items){
echo "<div class=$blocks[$key]> ". is_array($items) ? implode($items) : $items  ."</div>";
}
 
 
Homersx
  • 5
  • 3

0 Answers0