Display array values in PHP

前端 未结 9 2281
名媛妹妹
名媛妹妹 2020-12-01 07:51

So, I\'m working with PHP for the first time and I am trying to retrieve and display the values of an array. After a lot of googling, the only methods I can find for this ar

9条回答
  •  长情又很酷
    2020-12-01 07:53

    There is foreach loop in php. You have to traverse the array.

    foreach($array as $key => $value)
    {
      echo $key." has the value". $value;
    }
    

    If you simply want to add commas between values, consider using implode

    $string=implode(",",$array);
    echo $string;
    

提交回复
热议问题