如何从数据库中获取字符串以及如何在 codeigniter 中将其分解?

how to get string from database and how to explode it in codeigniter?

这是我的代码,我试图分解字符串,但出现了一些错误, 我有绳子,但我没有爆炸, 在这里我得到了一些错误,我无法理解 遇到了 PHP 错误

Severity: Warning Message: explode() expects parameter 2 to be string, object given Filename: views/testing.php Line Number: 65

这是我的代码:

<?php

foreach ($test as $t)   
{                      
   echo $t->user_rights;
   $t=(explode(",", $t));                                   


 }

?>

也许你可以使用 implode($t) 转换 $t。 如: $t= 爆炸(",", 内爆($t));

希望对您有所帮助:

foreach ($test as $t)   
{   
    /* this will trigger an error since $t->user_rights is an array . 
       To use explode $t->user_rights should be a string
    */                  
    $user_rights = (explode(",", $t->user_rights));
    print_r($user_rights);                                   
}

更新:

如果你想要 user_rights 的逗号分隔值,那么你必须使用 implode() 而不是 explode();

foreach ($test as $t)   
{                      
    $user_rights = implode(",", $t->user_rights);
    echo $user_rights ;                                   
}

更多:http://php.net/manual/en/function.implode.php

<?php
foreach ($test as $t){
    $t=(explode(",",$t->user_rights));
}
?>