PHP, add a newline with implode

后端 未结 4 2030
忘了有多久
忘了有多久 2020-12-06 06:16

I\'m trying to add a newline \\n, in my foreach statement with implode.

My code:

$ga->requestReportData($profileId,array(\'country\'),a         


        
4条回答
  •  情话喂你
    2020-12-06 06:36

    I suspect it is because you are echoing the data to the browser and it's not showing the line break as you expect. If you wrap your implode in the the

     tags, you can see it is working properly.

    Additionally, your arguments are backwards on your implode function, according to current documentation. However, for historical reasons, parameters can be in either order.

    $array = array('this','is','an','array');
    echo "
    ".implode(",\n",$array)."
    ";

    Output:

    this,
    is,
    an,
    array
    

提交回复
热议问题