Here is my code i tried to explode string, but get some errors, i got string but i did not explode, Here i getting some erros,i cant understand it A PHP Error was encountered
Severity: Warning Message: explode() expects parameter 2 to be string, object given Filename: views/testing.php Line Number: 65
Here is My code:
<?php
foreach ($test as $t)
{
echo $t->user_rights;
$t=(explode(",", $t));
}
?>
Hope this will help you :
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);
}
UPDATE :
If you want a comma separated values of user_rights
then you have to use implode()
instead of explode()
;
foreach ($test as $t)
{
$user_rights = implode(",", $t->user_rights);
echo $user_rights ;
}