如何修复 PHP/HTML 中的数组到字符串转换问题?

How to fix Array to string conversion Issue in PHP/HTML?

详情

这是我尝试过的

<?php 

foreach(array_unique(array_values($continent)) as $continent_id){

    if($continent_id == 1 ){ $continent == "Europe" ; } 
    elseif ($continent_id == 2 ){ $continent == "Asia" ; } 
    elseif ($continent_id == 3 ){ $continent == "North America" ; } 
    elseif ($continent_id == 4 ){ $continent == "Oceania" ; } 
    elseif ($continent_id == 5 ){ $continent == "South America" ; } 
    else { $continent == "Africa" ; } 



    echo '<h1>#'.$continent."</h1>";

这是我得到的

我收到这条错误消息

数组到字符串的转换(查看:C:\wamp\www\distributor-application\laravel\app\views\jsons\decoding.blade.php)

谁能告诉我我错过了什么?

您正在与 $continent == "Europe"

进行比较

当你想分配$continent = "Europe"

对其他人做同样的改变。