Array to string conversion cakephp

前端 未结 4 1417
抹茶落季
抹茶落季 2021-01-29 14:30

I\'m working on Cake PHP. Please give me a solution to solve this:

Controller.php:

public function test() {
    $this->set(\'users_l         


        
4条回答
  •  Happy的楠姐
    2021-01-29 15:08

    You can use the String class. It has a very cool method called toList(), and it's used to print an array with an 'and' before the last element.

    App::uses('String', 'Utility');
    echo String::toList($users_list);
    

    Check out the documentation: http://book.cakephp.org/2.0/en/core-utility-libraries/string.html

提交回复
热议问题